【Golang】Golang 安装

Posted by 西维蜀黍 on 2020-07-24, Last Modified on 2024-05-02

Ubuntu

If you’re using Ubuntu 18.04 LTS or 19.10 on amd64, arm64, armhf or i386, then you can use the longsleep/golang-backports PPA and install Go 1.14.

$ sudo add-apt-repository ppa:longsleep/golang-backports
$ sudo apt update
$ sudo apt install golang-go

安装特定版本

$ curl -LO https://golang.org/dl/go1.14.6.linux-amd64.tar.gz

$ sudo tar -C /usr/local -xzf go1.15.2.linux-amd64.tar.gz

Add /usr/local/go/bin to the PATH environment variable.

You can do this by adding the following line to your $HOME/.profile or /etc/profile (for a system-wide installation):

export PATH=$PATH:/usr/local/go/bin

Note: Changes made to a profile file may not apply until the next time you log into your computer. To apply the changes immediately, just run the shell commands directly or execute them from the profile using a command such as source $HOME/.profile.

Verify that you’ve installed Go by opening a command prompt and typing the following command:

$ go version

macOS

Download from https://go.dev/dl/

Installing multiple Go versions

Refer to https://go.dev/doc/manage-install

Reference