Installation steps: 1. Open the terminal (Ctrl Alt T); 2. Add the official repository of Go; 3. Update the package list; 4. Install Go; 5. Enter the "go version" command to verify the installation. It depends on whether it is successful or not. Detailed introduction: 1. If you want to install a specific version of Go, use the "apt show golang-go" command to view the available versions, and then use the "sudo apt install golang-go=
" command to install the specific version. .
To install Go (Golang) on Ubuntu, you can follow the steps below:
1. Open the terminal (Ctrl Alt T ).
2. Add Go’s official repository. Enter the following command in the terminal and press Enter:
sudo add-apt-repository ppa:longsleep/golang-backports
3. Update the package list:
sudo apt update
4. Install Go:
sudo apt install golang-go
5. Verify whether the installation is successful . Enter the following command:
go version
If the installation is successful, you will see the version information of Go.
Please note that the above steps will install the default version of Go. If you want to install a specific version of Go, use the apt show golang-go command to view the available versions, then use the following command to install the specific version:
sudo apt install golang-go=<版本号>
Replace
After the installation is complete, you can also set Go's working environment variables. You can add the following to your ~/.bashrc or ~/.zshrc file:
export PATH=$PATH:/usr/lib/go-<版本号>/bin export GOPATH=$HOME/go export PATH=$PATH:$GOPATH/bin
Please replace
The above is the detailed content of How to install golang on ubuntu. For more information, please follow other related articles on the PHP Chinese website!