GoLang Installation

GoLang - Installation

https://go.dev/doc/install

(macOS) If you can avoid it, do not install go with homebrew at all.

And if the reason for using Homebrew is ease of updates, there’s always goup. https://github.com/lpar/goup

There are Go version managers (like goenv) that let you install multiple versions of go without polluting global PATH/GOBIN/GOPATH. https://github.com/go-nv/goenv

To add go lang to path

(Linux)

Run

[explorer436@explorer436-p50-20eqs27p03 ~]$ whereis go
go: /usr/bin/go /usr/lib/go /usr/src/debug/go

Grab the path and use it here.

export GOROOT=/usr/lib/go
export GOPATH=$HOME/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

Where does go get install packages?

https://stackoverflow.com/questions/50633092/where-does-go-get-install-packages

go env

You can get the path from GOMODCACHE

go env GOMODCACHE

Cleaning them up

go clean -modcache

go install command

https://github.com/actions/setup-go/issues/27

Sometimes, Binaries installed via go install are not accessible on path.

This should work by default but for now you can add to each step:

export PATH=${PATH}:`go env GOPATH`/bin

Links to this note