Before testing Go applications in a local development environment, you must prepare the development environment. This topic describes how to configure a Go development environment. It also provides download links for related tools.

Install Go

Download an installation package that corresponds to your operating system from the Go official website. Go is compatible with multiple mainstream operating systems. Follow the steps specific to your operating system to install the package.

Linux

  1. Use the following command to extract files that are included in the installation package to a directory named /usr/local/go.
    tar -C /usr/local -xzf go$VERSION. $OS-$ARCH.tar.gz
  2. After the extraction is complete, you can add the directory where the executable installation file resides to the PATH environment variable. Then, add the following command to the /etc/profile file or $HOME/.profile file.
    export PATH=$PATH:/usr/local/go/bin
  3. Use the following command to enable the environment variable.
    source $HOME/.profile

macOS

Use the following brew command to install Go.
brew update && brew install go

Windows

Open the directory where the Go installation package resides and run the .msi file to install the package. No extra setting is required.

Configure GOPATH

The GOPATH environment variable identifies the directory of a workspace. In most cases, you need to configure this environment variable to specify the directory of a working area. For more information about the procedure for configuring the environment variable specific to an operating system, see Setting GOPATH.

Install an IDE

An integrated development environment (IDE) is a software application that provides developers with comprehensive tools for software development. Typically, these tools include a code editor, compiler, and debugger, and graphical user interface (GUI). These tools help developers significantly improve development efficiency. The following lists commonly used IDEs for developing Go applications. For these IDEs, you may need to install extra plug-ins to support the development of Go applications.