Hi there, welcome back, hope you read the introduction blog and are ready to install Go.
Installing Go is trivial, you can download the binaries for your platform from the Go’s download page and install it.
In this blog, we will install Go v1.11 and go through the steps of installation on macOS and Ubuntu operating systems.
Install Go v1.11.2 on Mac 10
Step 1: Download the package file from https://golang.org/doc/install?download=go1.11.2.darwin-amd64.pkg
Step 2: Open the package file and follow the prompts and that’s it – Go will be installed
Step 3: Check that the package will be installed in /usr/local/go folder and the PATH environment variable will be updated with /usr/local/go/bin
Step 4: Open the terminal and run go version command, you should see the below output, which confirms the go installation and prints the installed version as well
chetan:~ chetan$ go version go version go1.11 darwin/amd64
Install Go v1.11.2 on Ubuntu 16.04
Step1: Make sure you update your packages, security patches and fixes by running these commands on Ubuntu:
ubuntu:~$ sudo apt-get update ubuntu:~$ sudo apt-get -y upgrade
Step 2: Begin downloading the latest Go package from the downloads page using our very own curl command:
ubuntu:~$ curl -O https://storage.googleapis.com/golang/go1.11.2.linux-amd64.tar.gz
Step 3: Unzip the gzip file using the tar command, you will get the ‘go‘ folder after unzipping the contents. Now move the ‘go‘ folder to /usr/local/ (like in macOS installation)
ubuntu:~$ tar -xvf go1.11.2.linux-amd64.tar.gz ubuntu:~$ sudo mv go /usr/local
Step 4: Use /usr/local/go/bin path to update your bash profile with PATH environment variable like the macOS installer did for us. You can also create a folder, say go-work under your home directory (in my case /home/ubuntu), this is where all our go related source code will go in. Don’t worry too much about GOPATH for now, we understand more about it in the next blog
ubuntu:~$ echo $HOME /home/ubuntu ubuntu:~$ mkdir go-work ubuntu:~$ vi ~/.bashrc export GOPATH=$HOME/go-work export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
Step 5: Now reload your ~/.bashrc file (use appropriate profile file based on the shell you use, for instance use ~/.zshrc if you’re using zsh) and type go version on your terminal. And you’re done!
ubuntu:~$ source ~/.bashrc ubuntu:~$ go version go version go1.11.2 linux/amd64
So now we have Go v1.11 installed on macOS and Ubuntu. Hurray! 🙂
But we haven’t written any code yet and what about the Editor? Let’s look at them in our next blog.