patterngoCritical
What should be the values of GOPATH and GOROOT?
Viewed 0 times
gorootshouldandthevalueswhatgopath
Problem
I'm trying to install doozer like this:
I get these errors.
$ goinstall github.com/ha/doozerI get these errors.
goinstall: os: go/build: package could not be found locally
goinstall: fmt: go/build: package could not be found locally
goinstall: io: go/build: package could not be found locally
goinstall: reflect: go/build: package could not be found locally
goinstall: math: go/build: package could not be found locally
goinstall: rand: go/build: package could not be found locally
goinstall: url: go/build: package could not be found locally
goinstall: net: go/build: package could not be found locally
goinstall: sync: go/build: package could not be found locally
goinstall: runtime: go/build: package could not be found locally
goinstall: strings: go/build: package could not be found locally
goinstall: sort: go/build: package could not be found locally
goinstall: strconv: go/build: package could not be found locally
goinstall: bytes: go/build: package could not be found locally
goinstall: log: go/build: package could not be found locally
goinstall: encoding/binary: go/build: package could not be found locallySolution
GOPATH is discussed in the cmd/go documentation:The
GOPATH environment variable lists places to look for Go code. OnUnix, the value is a colon-separated string. On Windows, the value is
a semicolon-separated string. On Plan 9, the value is a list.
GOPATH must be set to get, build and install packages outside thestandard Go tree.
Set
GOPATH to a custom directory for installing downloaded packages.GOROOT is discussed in the installation instructions:The Go binary distributions assume they will be installed in
/usr/local/go (or c:\Go under Windows), but it is possible to installthe Go tools to a different location. In this case you must set the
GOROOT environment variable to point to the directory in which it wasinstalled.
For example, if you installed Go to your home directory you should add
the following commands to
$HOME/.profile:export GOROOT=$HOME/go
export PATH=$PATH:$GOROOT/binNote:
GOROOT must be set only when installing to a custom location.As of CY2023, for any modern Go installation, do not set/export
GOROOT.(updated version of Chris Bunch's answer.)
Code Snippets
export GOROOT=$HOME/go
export PATH=$PATH:$GOROOT/binContext
Stack Overflow Q#7970390, score: 453
Revisions (0)
No revisions yet.