ubunut install golang

ubunut install golang

来源 https://www.cnblogs.com/dream397/p/13535058.html

参考 https://golang.google.cn/

 

If you're using Ubuntu 18.04 LTS or 20.04 LTS on amd64, arm64, armhf or i386, then you can use the longsleep/golang-backports PPA and update to Go 1.15.

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

Note that golang-go installs latest Go as default Go. If you do not want that, install golang-1.15 instead and use the binaries from /usr/lib/go-1.15/bin.

If that's too new for you, try: (Ubuntu 19.04 max)

$ sudo add-apt-repository ppa:gophers/archive
$ sudo apt update
$ sudo apt install golang-1.11-go

Note that golang-1.11-go puts binaries in /usr/lib/go-1.11/bin. If you want them on your PATH, you need to make that change yourself.

Using snaps also works quite well:

$ sudo snap install --classic go

A restart may or may not be required for the command to be recognized depending on your system.

Using getgo (proof-of-concept command-line installer for Go):

curl -LO https://get.golang.org/$(uname)/go_installer && chmod +x go_installer && ./go_installer && rm go_installer

 

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/lsgx/.cache/go-build"
GOENV="/home/lsgx/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/lsgx/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/lsgx/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go-1.15"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.15/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build522554850=/tmp/go-build -gno-record-gcc-switches"

 

export GOROOT="/usr/lib/go-1.15"
export PATH=$PATH:$GOROOT/bin

export GO111MODULE=on
export GOPROXY="https://goproxy.cn"

go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct

 

=========== End

 

posted @ 2020-12-21 09:32  lsgxeva  阅读(204)  评论(0编辑  收藏  举报