Skip to content

Instantly share code, notes, and snippets.

@momota
Created November 6, 2018 08:03
Show Gist options
  • Select an option

  • Save momota/2d7ddb594193789ad5d6c1c5ad861df8 to your computer and use it in GitHub Desktop.

Select an option

Save momota/2d7ddb594193789ad5d6c1c5ad861df8 to your computer and use it in GitHub Desktop.

Revisions

  1. momota created this gist Nov 6, 2018.
    57 changes: 57 additions & 0 deletions install-golang-on-ubuntu.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,57 @@
    # Environment

    ```sh
    $ cat /etc/lsb-release
    DISTRIB_ID=Ubuntu
    DISTRIB_RELEASE=18.04
    DISTRIB_CODENAME=bionic
    DISTRIB_DESCRIPTION="Ubuntu 18.04.1 LTS"


    $ go version

    Command 'go' not found, but can be installed with:

    sudo snap install go # version 1.11.2, or
    sudo apt install golang-go
    sudo apt install gccgo-go

    See 'snap info go' for additional versions.
    ```


    # Installation latest golang (1.11.2)

    Obey [Ubuntu · golang/go Wiki](https://github.com/golang/go/wiki/Ubuntu).

    ```
    $ sudo snap install --classic go
    go 1.11.2 from Michael Hudson-Doyle (mwhudson) installed
    $ go version
    go version go1.11.2 linux/amd64
    ```

    ## You can not install latest version of golang via apt.

    ```sh
    $ sudo apt-get update
    $ sudo apt-cache search golang | grep 1.1
    golang-1.10 - Go programming language compiler - metapackage
    golang-1.10-doc - Go programming language - documentation
    golang-1.10-go - Go programming language compiler, linker, compiled stdlib
    golang-1.10-race-detector-runtime - Runtime support for Go's race detector
    golang-1.10-src - Go programming language - source files
    golang-github-twinj-uuid-dev - RFC 4122 and DCE 1.1 compliant UUIDs in Go
    # => We can not find golang-1.11*
    ```
    # Setting GOPATH
    Just add the following lines to `~/.bashrc` (or `~/.zshrc`, `~/.config/fish/config.fish` and so on) and this will persist.
    ```sh
    export GOPATH=$HOME/go
    export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
    ```