How to install the current version of Go in Ubuntu Precise

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

提交回复
热议问题