From charlesreid1

(Created page with "=Installing Go= ==Linux== Visit the Go downloads page: https://golang.org/dl Get the URL for the latest version of Go Download go: <pre> curl -O https://dl.google.com/go/...")
 
Line 46: Line 46:
Edit your <code>.profile</code> to make the following changes to your environment variables:
Edit your <code>.profile</code> to make the following changes to your environment variables:


* GOROOT - this is /usr/local by default, the location of your Go tree
* GOROOT - (by default, this is /usr/local, not necessary to change) the location of your Go tree
* GOPATH - this is a list of paths in which Go code, packages, objects, and executables are stored
* GOPATH - this is a list of paths in which Go code, packages, objects, and executables are stored
* PATH - update PATH to include the binary folder of both GOROOT and GOPATH
* PATH - update PATH to include the binary folder of both GOROOT and GOPATH


For example, if Go were installed to the home directory in <code>go/</code> and <code>work/</code>, these lines would be added to the user's .profile file:
For example, if Go were installed to the home directory in <code>go/</code> and <code>work/</code>, these lines would be added to the user's <code>.profile</code> file:


<pre>
<pre>

Revision as of 00:34, 7 December 2018

Installing Go

Linux

Visit the Go downloads page: https://golang.org/dl

Get the URL for the latest version of Go

Download go:

curl -O https://dl.google.com/go/go1.11.2.linux-amd64.tar.gz

Verify checksum:

sha256sum go*.tar.gz

Now you're ready to install Go:

tar xvf go*.tar.gz

sudo chown -R root:root ./go

sudo mv go /usr/local

Mac

brew install go
brew upgrade go

Goenv

Following the successful model of pyenv, you can use goenv to set up and manage various side-by-side versions of Go.

Link: https://github.com/syndbg/goenv

Paths

Edit your .profile to make the following changes to your environment variables:

  • GOROOT - (by default, this is /usr/local, not necessary to change) the location of your Go tree
  • GOPATH - this is a list of paths in which Go code, packages, objects, and executables are stored
  • PATH - update PATH to include the binary folder of both GOROOT and GOPATH

For example, if Go were installed to the home directory in go/ and work/, these lines would be added to the user's .profile file:

export GOROOT=$HOME/go
export GOPATH=$HOME/work
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin