Skip to content

Installing Go

zelenko edited this page Feb 11, 2024 · 16 revisions

Go Resorces

Download GO Packages

Packages are downloaded into folder specified in the $GOPATH system varible:

go get -u gopkg.in/mgo.v2

The 'go get' command requires that the git is installed on Windows. $GOPATH has bin, pkg sub-directories. $GOROOT/src is where the source code for the standard library lives.


Build on Linux

  • export GOPATH=/var/go/web/
  • echo $GOPATH
GOOS=linux GOARCH=amd64 go build -o web

Build on Windows

  • set GOARCH=amd64
  • set GOARCH=386
  • set GOOS=linux
  • set GOOS=windows
  • echo %GOROOT%
go build -o hello.exe hello.go

List of GOOS/GOARCH supported by Go

Installing GO on Debian

cd /usr/local
curl -LO https://redirector.gvt1.com/edgedl/go/go1.9.2.linux-amd64.tar.gz
shasum -a 256 go1.9.2.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.9.2.linux-amd64.tar.gz

vi ~/.profile

export PATH=$PATH:/usr/local/go/bin
export GOROOT=/usr/local/go
export GOPATH=/var/go
export GOPROXY=https://proxy.golang.org,direct

source ~/.profile

echo $GOROOT

Installing GO on Windows

After downloading and installing, specify where the code is stored in system variable. CLI command: set GOPATH=F:\GoCode

Check existing variables go env. Check current version go version.

Installing golint

To download it run:

go get -u github.com/golang/lint/golint

To build it run:

go build github.com/golang/lint/golint

To use it run:

golint ./...

Go tools

  • gocode
  • gopkgs
  • go-outline
  • go-symbols
  • guru
  • gorename
  • dlv
  • godef
  • goreturns
  • golint

Clone this wiki locally