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.
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.
- 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
- 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.
- Use the following command to enable the environment variable.
brew update && brew install go
Open the directory where the Go installation package resides and run the .msi file to install the package. No extra setting is required.
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.