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
+18.4k Golang : How to count the number of repeated characters in a string?
+4.3k Golang : Issue HTTP commands to server and port example
+6.1k Golang : Use modern ciphers only in secure connection
+17k Golang : Implement getters and setters
+22.7k Golang : How to print rune, unicode, utf-8 and non-ASCII CJK(Chinese/Japanese/Korean) characters?
+9.6k PHP : Convert(cast) bigInt to string
+6.3k Golang : Example of how to detect which type of script a word belongs to
+4.3k Unix/Linux : How to archive and compress entire directory ?
+29.5k error: trying to remove "yum", which is protected
+28.6k Get client IP Address in Go
+13.6k nginx: [emerg] unknown directive "ssl"
+10.6k Golang : md5 hash of a string