Golang : package is not in GOROOT during compilation
Alright, just putting down here for my own future reference, in case of future encounter with this weird error message during compilation process.
package xxx is not in GOROOT
Basically the problem is caused by go modules. To fix this problem, first check your Golang's environment with go env
to see if GO111MODULE=on
If yes, then set it to OFF.
If you're using a build script to compile your code. Remember to SET GO111MODULE=off
Before compiling, best to clean up the module cache by issuing this command.
go clean --modcache
Hope this helps and happy coding!
Reference :
https://dev.to/maelvls/why-is-go111module-everywhere-and-everything-about-go-modules-24k
See also : Golang : How to solve "too many .rsrc sections" error?
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+9.7k Golang : ffmpeg with os/exec.Command() returns non-zero status
+36.3k Golang : Validate IP address
+9.6k Golang : interface - when and where to use examples
+23k Golang : Print out struct values in string format
+6.9k Golang : Gargish-English language translator
+22.7k Golang : simulate tail -f or read last line from log file example
+9k Golang : Gonum standard normal random numbers example
+13.3k Golang : Count number of runes in string
+62.5k Golang : Convert HTTP Response body to string
+22k Golang : Securing password with salt
+8.7k Golang : Get final balance from bit coin address example
+8.9k Golang : io.Reader causing panic: runtime error: invalid memory address or nil pointer dereference