Golang Installation Files Usage Guide
Some content in this document may have been translated by AI.
Golang Introduction
Golang is an open-source project aimed at improving programmer productivity.
Go is expressive, concise, clean, and efficient. Its concurrency mechanisms make it easy to write programs that make full use of multi-core and networked machines, while its novel type system enables flexible and modular program construction.
Go can quickly compile to machine code while also having the convenience of garbage collection and the powerful functionality of runtime reflection. It is a fast, statically typed compiled language that feels like a dynamically typed interpreted language.
Golang Installation
The mirror site provides installation packages for Golang on four platforms: Linux/Windows/Mac/FreeBSD. Please download the installation package corresponding to your system.
Linux/FreeBSD Installation
-
First download the installation package corresponding to your system and architecture from the download page, or use the following command to download:
# use wget
wget https://mirrors.hust.edu.cn/golang/<version>.linux-<arch>.tar.gz
# use curl
curl -O https://mirrors.hust.edu.cn/golang/go<version>.linux-<arch>.tar.gz -
After downloading, if Golang was previously installed, execute the following command to remove it:
Whether root usersudo rm -rf /usr/local/go -
After removal, execute the following command to extract the binary files to the system path:
Whether root usersudo tar -C /usr/local -xzf go<version>.linux-<arch>.tar.gz -
Add the Golang executable file path to the environment variable
PATH:# Only effective for current terminal
export PATH=$PATH:/usr/local/go/bin
# Long-term effective
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.zshrc # If using zsh
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc # If using bash -
Verify installation, open a new terminal and enter:
go version
If the downloaded Golang version is printed, Golang installation is successful.
Windows Installation
-
First download the installation package corresponding to your system and architecture from the download page. It is recommended to download the MSI package.
-
Open the downloaded MSI file and follow the prompts to install Golang.
cautionAfter installation is complete, if you have an open terminal or command prompt, you need to reopen it to use the
gocommand. -
Verify installation, open terminal or command prompt and enter:
go version
If the downloaded Golang version is printed, Golang installation is successful.
Mac Installation
-
First download the installation package corresponding to your system and architecture from the download page. It is recommended to download the pkg package.
-
Open the downloaded pkg file and follow the prompts to install Golang. The installation package will install Golang to the
usr/local/godirectory and add this directory to the environment variablePATH. -
Verify installation, open terminal or command prompt and enter:
go version
If the downloaded Golang version is printed, Golang installation is successful.