This is a creation in Article, where the information may have evolved or changed.
There is many ways to configure the Go development environment on your computer, where can choose any one of your like. The three most common ways is as follows.
1, official installation packages
The Go team provides convenient installation packages in Windows, Linux, Mac
and other operating systems. The easiest to get started.
2. Install from source code
Popular with developers, who is familiar with unix-like systems.
3. Use Third-party Tools
There is many third-party tools and package managers for installing Go, like apt-
Get in Ubuntu and homebrew for Mac.
Want to install more than one version of Go on one computer, you should take a look at the tool called GVM. It's the best tool I ' ve seen so far for achieving this job, otherwise you had to know how to deal with this problem by Y Ourself.
The first method of installation
Using GVM
- Make sure to install pre-requisite libraries first
sudo apt-get update
sudo apt-get install curl git mercurial make binutils bison gcc
- Install GVM
Bash < < (curl-s Https://raw.github.com/moovweb/gvm/master/binscripts/gvm-installer)
- Install Go
GVM Install go1.2
GVM use go1.1.2 [–default]
GVM List
The second method of installation
Install Go Binary
- Install Required Libraries
sudo apt-get install python-software-properties # 12.04
sudo add-apt-repository Ppa:duh/golang
sudo apt-get update
- Install Go
sudo apt-get install Golang
- Export the settings you ' re gonna need to BASH_RC or equivalent:
Export Goroot=/usr/lib/go
Export gobin=/usr/bin/g
Third method of installation
From Source
- Dependencies
sudo apt-get update
sudo apt-get install gcc make mercurial git libc6-de
- Building from Source
HG Clone-u Release Https://code.google.com/p/go
Cd g o/sRC ./all.bas
- The GOPATH environment variable
Go commands all rely on one important environment variable which is called GOP AT H .N oTICeThaTThIsIsNoTThe Goroot where Go is installed. This variable points to the workspace of Go in your computer. (I Use this path in My computer, if you don't have the same directory structure, please replace by yourself.)
Export gopath= H OM E /g oCod eexPoRTP AT H = PATH: $GOPATH/bin
note:-If your Go version is greater than 1.0 and you don't have the to set GOBI N ,aNd ITWILLauTomaTICaLLy beReLaTed Toy ouR Goroot/bin, which we'll talk on the next section
You can install any of the above three. I mostly prefer using GVM. I hope it would help you.!