How to Install Go on Ubuntu
Updated by Linode Written by Linode

What is Go?
Go is a compiled, statically typed programming language developed by Google. Many modern applications such as Docker, Kubernetes, and Caddy are written in Go.
Install Go
- Use - curlor- wgetto download the current binary for Go from the official download page. As of this writing, the current version is 1.12.9. Check the download page for updates, and replace- 1.12.9with the most recent stable version if necessary.- curl -O https://storage.googleapis.com/golang/go1.12.9.linux-amd64.tar.gz
- Verify the - .tarfile using- sha256sum:- sha256sum go1.12.9.linux-amd64.tar.gz- aac2a6efcc1f5ec8bdc0db0a988bb1d301d64b6d61b7e8d9e42f662fbb75a2b9b go1.12.9.linux-amd64.tar.gz
- Extract the tarball: - tar -xvf go1.12.9.linux-amd64.tar.gz
- Adjust the permissions and move the - godirectory to- /usr/local:- sudo chown -R root:root ./go sudo mv go /usr/local
Adjust the Path Variable
- Using a text editor, open the - ~/.profilefile and add the following two lines to the bottom of the file:- ~/.profile
- 
1 2export GOPATH=$HOME/go export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
 
- Save the file, and load the commands into the current shell instance: - source ~/.profile
Test the Installation
According to the official documentation, the following steps are the recommended way to test the success of the installation:
- In your home directory create a folder named - go, this will be your workspace:- mkdir go
- Within that directory create - /src/helloand within that directory copy and paste the contents of the file below:- mkdir -p go/src/hello && cd go/src/hello touch hello.go- hello.go
- 
1 2 3 4 5 6 7package main import "fmt" func main() { fmt.Printf("hello, world\n") }
 
- Build the - hello.gofile:- go build
- Run the script: - ./hello- hello, world
Join our Community
Find answers, ask questions, and help others.
This guide is published under a CC BY-ND 4.0 license.