How to install the current version of Go in Ubuntu Precise

前端 未结 17 1909
温柔的废话
温柔的废话 2021-01-29 19:08

Running sudo apt-get install golang-stable, I get Go version go1.0.3. Is there any way to install go1.1.1?

17条回答
  •  深忆病人
    2021-01-29 19:45

    1. Download say, go1.6beta1.linux-amd64.tar.gz from https://golang.org/dl/ into /tmp

    wget https://storage.googleapis.com/golang/go1.6beta1.linux-amd64.tar.gz -o /tmp/go1.6beta1.linux-amd64.tar.gz

    1. un-tar into /usr/local/bin

    sudo tar -zxvf go1.6beta1.linux-amd64.tar.gz -C /usr/local/bin/

    1. Set GOROOT, GOPATH, [on ubuntu add following to ~/.bashrc]

    mkdir ~/go export GOPATH=~/go export PATH=$PATH:$GOPATH/bin export GOROOT=/usr/local/bin/go export PATH=$PATH:$GOROOT/bin

    1. Verify

    go version should show be

    go version go1.6beta1 linux/amd64

    go env should show be

    GOARCH="amd64" GOBIN="" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPATH="/home/vats/go" GORACE="" GOROOT="/usr/local/bin/go" GOTOOLDIR="/usr/local/bin/go/pkg/tool/linux_amd64" GO15VENDOREXPERIMENT="1" CC="gcc" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0" CXX="g++" CGO_ENABLED="1"

提交回复
热议问题