Home >Backend Development >Golang >How to install golang
Windows system: 1. Download the Go installation program; 2. Run the installation program; 3. Configure environment variables; 4. Verify the installation; macOS system: 1. Use Homebrew to install; 2. Configure environment variables; 3 , Verify the installation; Linux system: 1. Download and decompress the Go compressed package; 2. Configure environment variables; 3. Make the configuration take effect; 4. Verify the installation.
The operating system for this tutorial: Windows 10 system, Go version 1.21, DELL G3 computer.
Installing the Go programming language is very simple. The following is an installation tutorial for common operating systems:
Windows
#1. Download the Go installation program ( msi file): Download the installer for Windows on the official download page.
2. Run the installation program: double-click the downloaded msi file and follow the prompts to install. Select the installation location and other options, then click the "Install" button.
3. Configure environment variables:
Right-click "This Computer" and select "Properties".
Click "Advanced System Settings" and then click "Environment Variables".
In the system variables, select "Path" and click "Edit".
In the pop-up window, click "New" and enter the installation path of Go (for example, C:\Go\bin).
4. Verify the installation: Open the command prompt (cmd) and enter go version. If the Go version information is output, the installation is successful.
macOS
1. Install using Homebrew: Run the following command in the terminal to install Go
brew install go
2. Configure environment variables: Open the terminal and enter The following command adds the Go installation path to the environment variable
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bash_profile source ~/.bash_profile
3. Verify the installation: Enter go version in the terminal. If the Go version information is output, the installation is successful.
Linux
1. Download and decompress the Go compressed package:
wget https://golang.org/dl/go1.17.2.linux-amd64.tar.gz sudo tar -C /usr/local -xzf go1.17.2.linux-amd64.tar.gz
2. Configure environment variables: Open the terminal and edit ~/.profile Or ~/.bashrc file, add the following lines:
export PATH=$PATH:/usr/local/go/bin
3. Make the configuration effective:
source ~/.profile
4. Verify the installation: enter go version in the terminal, if the version information of Go is output , indicating that the installation is successful.
The above are the simple steps to install the Go programming language on Windows, macOS and Linux. Once the installation is complete, you can start developing applications with Go.
The above is the detailed content of How to install golang. For more information, please follow other related articles on the PHP Chinese website!