How to install the current version of Go in Ubuntu Precise

前端 未结 17 1947
温柔的废话
温柔的废话 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条回答
  •  猫巷女王i
    2021-01-29 19:29

    I use this instruction to install the latest version of IMG:

    1. Remove the existing Go version:

      sudo apt-get purge golang*
      
    2. Install the latest version of Go:

      sudo add-apt-repository ppa:longsleep/golang-backports
      sudo apt-get update
      sudo apt-get install golang-go
      
    3. Create the .profile file in the home path with this content:

      # ~/.profile: executed by the command interpreter for login shells.
      # This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
      # exists.
      # see /usr/share/doc/bash/examples/startup-files for examples.
      # the files are located in the bash-doc package.
      
      # the default umask is set in /etc/profile; for setting the umask
      # for ssh logins, install and configure the libpam-umask package.
      #umask 022
      
      # if running bash
      if [ -n "$BASH_VERSION" ]; then
          # include .bashrc if it exists
          if [ -f "$HOME/.bashrc" ]; then
              . "$HOME/.bashrc"
          fi
      fi
      
      # set PATH so it includes user's private bin directories
      PATH="$HOME/bin:$HOME/.local/bin:$PATH"
      
    4. Set Go workspace to the environment variable:

      GOPATH=~/.go
      
    5. Apply the .profile configuration:

      source ~/.profile
      

    Test:

    $ go version
    go version go1.11.1 linux/amd64
    

    Ref: Go-GitHub-Installation

提交回复
热议问题