How to install golang

zbt
Release: 2023-12-13 13:59:57
Original
651 people have browsed it

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.

How to install golang

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
Copy after login

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
Copy after login

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
Copy after login

2. Configure environment variables: Open the terminal and edit ~/.profile Or ~/.bashrc file, add the following lines:

export PATH=$PATH:/usr/local/go/bin
Copy after login

3. Make the configuration effective:

source ~/.profile
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!