Install Go

Share on:

The Go programming language is an open source project to make programmers more productive.
Go is expressive, concise, clean, and efficient. Its concurrency mechanisms make it easy to write programs that get the most out of multicore and networked machines, while its novel type system enables flexible and modular program construction. Go compiles quickly to machine code yet has the convenience of garbage collection and the power of run-time reflection. It's a fast, statically typed, compiled language that feels like a dynamically typed, interpreted language.

Version

  1. Select a stable version of Go by visitng golang.org

  2. Create an environment variable to store the version e.g.

1GOLANG_VERSION="1.15"

Install

  1. Download the Linux (i.e. x86-64) Go package

    1curl -Lo /tmp/go${GOLANG_VERSION}.linux-amd64.tar.gz https://golang.org/dl/go${GOLANG_VERSION}.linux-amd64.tar.gz
    
  2. Install the package into /usr/local

    1sudo tar -C /usr/local -xzf /tmp/go${GOLANG_VERSION}.linux-amd64.tar.gz
    
  3. Edit .bashrc setting and add the installation directory to the path

    1vi ~/.bashrc
    
  4. Insert the following configuration at the bottom of the .bashrc file

    1# set PATH so it includes go installation if it exists
    2if [ -d "/usr/local/go/bin" ] ; then
    3  # export GOPATH=$HOME/go
    4  PATH="/usr/local/go/bin:$PATH"
    5fi
    
  5. Activate the updated settings

    1source ~/.bashrc
    
  6. Check the installation matches the installation version

    1go version
    

The above command will output the version of Go installed e.g.

1go version go1.15 linux/amd64