In general 1 there is no need to set the $GOROOT environment variable when compiling or using Go 1.0 or later. In fact, setting $GOROOT can lead to difficult-to-debug problems when multiple versions of Go are present on your computer. You still need to set $GOPATH.
What should Goroot be set to?
As mentioned above: The GOPATH environment variable specifies the location of your workspace. As for GOROOT, Go 1.9 will automatically put it on its installation path. Even if you have several GB installed, go to 1.9. 23
Is Gopath still needed?
no While it is possible to create multiple modules in the same project, this is almost always unnecessary. If you want a subfolder to organize your Go code, look for packages, not modules. You should only run the go mod init command once per project, no more. 26
Where do I configure Gopath?
The GOPATH environment variable specifies the location of your workspace. By default, this is a directory called go in your home directory, so $HOME/go on Unix, $home/go on Plan 9, and %USERPROFILE%\go (usually C:\Users\YourName\ \go ) under it Windows.
Where do you put Goroot?
You also don’t need to set the $GOROOT variable. $GOPATH is also set to a default directory, it is set to your user’s home directory in your operating system. For example, the default is ~/go on my Mac. You can change it to any other directory if you like, but keep it for now. 27
what is my background
The $GOPATH/bin directory is where Go puts the binaries that install builds. Our operating system uses the $PATH environment variable to find binary applications that can run without a full path. It is recommended to add this directory to our global $PATH variable. ten
How do I check my path?
By default, the GOPATH is assumed to be $HOME/go on Unix systems and %USERPROFILE%\go on Windows. If you are happy with this way, you don’t have to do anything. You can just create your workspace directory called go in the home folder and start writing Go code.
Is Gopath outdated?
On a Go blog, in the eight years that we’ve had GOPATH, an incredible amount of tools have been developed that assume the Go source code is stored in GOPATH. … Since version 1.12 Go modules are enabled by default and the GOPATH will be deprecated in version 1.13.
What is the default gopath?
The default GOPATH is: $HOME/go on Unix-like systems. %USERPROFILE%\go on Windows.