How to install the current version of Go in Ubuntu Precise

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

    Here is the most straight forward and simple method I found to install go on Ubuntu 14.04 without any ppa or any other tool.

    As of now, The version of GO is 1.7

    Get the Go 1.7.tar.gz using wget

    wget https://storage.googleapis.com/golang/go1.7.linux-amd64.tar.gz

    Extract it and copy it to /usr/local/

    sudo tar -C /usr/local -xzvf go1.7.linux-amd64.tar.gz

    You have now successfully installed GO. Now You have to set Environment Variables so you can use the go command from anywhere.

    To achieve this we need to add a line to .bashrc So,

    sudo nano ~/.bashrc

    and add the following line to the end of file.

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

    Now, All the commands in go/bin will work.

    Check if the install was successful by doing

    go version

    For offline Documentation you can do

    godoc -http=:6060

    Offline documentation will be available at http://localhost:6060

    NOTE:

    Some people here are suggesting to change the PATH variable.

    It is not a good choice.

    1. Changing that to /usr/local/go/bin is temporary and it'll reset once you close terminal.

    2. go command will only work in terminal in which you changed the value of PATH.

    3. You'll not be able to use any other command like ls, nano or just about everything because everything else is in /usr/bin or in other locations. All those things will stop working and it'll start giving you error.

    However, this is permanent and does not disturbs anything else.

提交回复
热议问题