"package XXX is not in GOROOT" when building a Go project
Solution 1:
You may have GO111MODULE set "on", which will be on the go mod. Turning off the GO111MODULE may resolve this problem.
go env -w GO111MODULE=off
Solution 2:
A pretty dumb conclusion (mostly on my part) but my issue came from having done go mod init
in each of the folders. after removing go.mod
and go.dep
from each of the folders I did go mod init
in, I could build without issue (through terminal)
Also, my packages in GoLand were not being detected because I had Go Modules enabled in the Settings. I disabled it and GoLand was able to index the external packages and my own packages.
Solution 3:
To anyone who does want modules to work with GoLand after they have stopped doing so, make sure 'Enable Go modules integration' is checked in the Preferences as such: