W3Basic Logo

Go Installation and Configuration

The very first step in your Go learning journey is to install the toolchain on your computer. It contains the compiler, the linker, the debugger, and other tools that you will use to write and run Go programs.


Installation

The installation process will depend on your operating system but is straightforward.

Windows

If you are using Windows (version 7 or later), you can download the installer from the official website. You just need to run it and follow the instructions.

Linux and macOS

While you can also download an installer for Linux and macOS, it is recommended to use a package manager instead. This way, you will only need to run a single command in your terminal (an application that can be found in the "Applications" folder on macOS and in the "System" menu on Linux) to install Go.

The exact command will depend on your distribution:

  • on Debian-based distributions (such as Ubuntu), type sudo apt install golang,
  • on Arch-based distributions (such as Manjaro), type sudo pacman -S go,
  • on macOS, type brew install go or port install go (depending on whether you use Homebrew or MacPorts).

Check the installation

To check that Go has been installed correctly, execute the go version command in your terminal. You should see something like this:

$ go version
go version go1.19.1 darwin/amd64

1.19 is the version of Go available at the time of writing. It is fine if you have a more recent version.

However, if the command is not found, you may need to add the Go binary to your PATH environment variable by editing your ~/.bashrc (or ~/.zshrc) file.

Configuration

Now that Go is installed, you may want to configure your code editor (the most popular one is Visual Studio Code by Microsoft) to highlight keywords, provide auto-completion, etc.

Visual Studio Code

In the "Extensions" tab of Visual Studio Code, search for "Go" and install the first extension that appears (the developer should be "Go Team at Google"). Many settings are available (for example to specify flags to the compiler, the linter, etc.) but the default ones are usually enough, especially for beginners.

© 2023 W3Basic. All rights reserved.

Follow Us: