Question:

Do you need both GOPATH and GOROOT variables, and why?

Answer:

Most of the time, you do not need them both. You need only the GOPATH variable set pointing to the Go packages tree or trees.

GOROOT points to the root of the Go language home directory, but it is most probably already set to the directory of the current Go language installation. It is easy to check whether it is so with the go env command:

$ go env
…
GOROOT=“/home/zabb/go”
…

It is necessary to set the GOROOT variable if there are multiple Go language versions on the same system or if the Go language has been downloaded as a binary package taken from the internet or transferred from another system.


Keywords:

© 2017 QuizBucket.org