In this tutorial you will learn about the Go Installation and its application with practical example.
Go Installation
Installing Go Language In Windows
In order to setup Go Programming development environment you need to have Go installed, so if you don’t have it installed, check the following instruction to get Go Language installed. If you’ve already have installed Go Language in your system, you can skip this part.
Step 1:- Download the Go Language Setup from the official Go Language website, link given below –
1 |
https://golang.org/dl/ |
Step 2:- Run the installer (the .msi file you downloaded in the previous step.)
Step 3:- Follow the installation wizard to install Go.
Step 4:- Select the Installation path and click next.
Step 5:- Now, lets open the terminal and run the following command in order to verify the Go Language installation.
1 |
go version |
Go Language Installation In Mac OS using HomeBrew
Step 1:- Enter the following command to get a list of updated programs.
1 |
$ brew update |
Step 2:- Now begin installation, by just typing following command.
1 2 3 4 5 6 7 8 9 10 11 12 |
$ brew install go ==> Downloading https://homebrew.bintray.com/bottles/go-1.5.1.yosemite.bottle.tar.gz ######################################################################## 100.0% ==> Pouring go-1.5.1.yosemite.bottle.tar.gz ==> Caveats As of go 1.2, a valid GOPATH is required to use the 'go get' command: https://golang.org/doc/code.html#GOPATH You may wish to add the GOROOT-based install location to your PATH: export PATH=$PATH:/usr/local/opt/go/libexec/bin ==> Summary (beer) /usr/local/Cellar/go/1.5.1: 5330 files, 273M |
if you get some error like failed with exit-2 or something like that, then you have to update/upgrade first using following commands –
1 2 3 |
$ brew upgrade OR $ brew update |
Step 3:- Set Path for Go
If all process finish, then you need to set Go PATH to your .bashrc or .zshrc
1 2 3 4 5 |
# .zshrc # go export GOROOT=/usr/local/opt/go/libexec export GOPATH=$HOME/.go export PATH=$PATH:$GOROOT/bin:$GOPATH/bin |
Step 3:- Now, lets open the terminal and run the following command in order to verify the Go Language installation.
1 |
$ go version |
Go Installation in Ubuntu
Step 1:- GoLang is available on official package repository of Ubuntu, you need to update the package repository of your Ubuntu with the following command.
1 |
$ sudo apt-get update |
Step 2:- Now you can install GoLang from the official repository of Ubuntu, by just typing following command.
1 |
$ sudo apt-get install golang |
Step 3:- Now, lets open the terminal and run the following command in order to verify the Go Language installation.
1 |
$ go version |