How to install the current version of Go in Ubuntu Precise

前端 未结 17 1906
温柔的废话
温柔的废话 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:40

    [October 2015] Answer because the current accepted answersudo apt-get install golang isn't uptodate and if you don't want to install GVM follow these steps.

    Step by step installation:

    1. Download the latest version here (OS: Linux).
    2. Open your terminal and go to your Downloads directory
    3. sudo tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz
    4. Add go to your path export PATH=$PATH:/usr/local/go/bin
    5. go version to check the current version installed
    6. Start programming.

    Possible errors + fixes: (to be updated)

    If you get a go version xgcc (Ubuntu 4.9.1-0ubuntu1) 4.9.1 linux/amd64 then you did something wrong, so check out this post: Go is printing xgcc version but not go installed version

    0 讨论(0)
  • 2021-01-29 19:41

    You can use a script from udhos/update-golang.

    Here is a two-liner as example (run as root):

    bash <(curl -s https://raw.githubusercontent.com/udhos/update-golang/master/update-golang.sh)
    ln -vs /usr/local/go/bin/go* /usr/local/bin/
    
    0 讨论(0)
  • 2021-01-29 19:43

    Best way to install Go on Ubuntu is to download required version from here. Here you could have all stable and releases, along with archived versions.

    after downloading you selected version you can follow further steps, i will suggest you to download tar.gz format for ubuntu machine:

    1. first of all fully remove the older version from your local by doing this

    sudo rm -rf /usr/local/go /usr/local/gocache

    this will remove all the local go code base but wait something more we have to do to remove fully from local, i was missing this step and it took so much time until I understood what i am missing so here is the purge stuff to remove from list

    sudo apt-get purge golang
    

    or

    sudo apt remove golang-go
    
    1. Now install / extract your downloaded version of go inside /usr/local/go, by hitting terminal with this

    tar -C /usr/local -xzf go1.10.8.linux-amd64.tar.gz

    1. after doing all above stuff , don't forget or check to GOROOT variable value you can check the value by go env if not set then export PATH=$PATH:/usr/local/go
    2. Better to test a small go program to make sure. write this inside /home/yourusername/go/test.php if you haven't changed set GOPATH value:
    package main
    
    import "fmt"
    
    func main() {
        fmt.Println("hello world")
    }
    
    1. run this by go run test.go

    i hope it works for you!!

    0 讨论(0)
  • 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"

    0 讨论(0)
  • 2021-01-29 19:46

    For the current release of Go:

    The Go Programming Language

    Getting Started

    Download the Go distribution

    Downloads

    Click the link above to visit the Go project's downloads page and select the binary distribution that matches your operating system and processor architecture.

    Official binary distributions are available for the FreeBSD, Linux, macOS, and Windows operating systems and the 32-bit (386) and 64-bit (amd64) x86 processor architectures.

    If a binary distribution is not available for your combination of operating system and architecture you may want to try installing from source or installing gccgo instead of gc.

    Installing Go from source

    0 讨论(0)
提交回复
热议问题