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
+15.6k Golang : How to check if a connection to database is still alive ?
+4.1k Mac OSX : Get a process/daemon status information
+15.1k Golang : Save map/struct to JSON or XML file
+6.7k Golang : Encrypt and decrypt data with x509 crypto
+2.2k Mac/Linux/Windows : Get CPU information from command line
+21.1k Golang : How to stream file to client(browser) or write to http.ResponseWriter?
+2k Golang : Find the length of big.Int variable example
+2.9k Golang : Dealing with postal or zip code example
+2.8k Golang : Getting Echo framework StartAutoTLS to work
+6.1k Golang : Interfacing with PayPal's IPN(Instant Payment Notification) example
+3.6k Golang : constant 20013 overflows byte error message
+2.7k Golang : Detect Pascal, Kebab, Screaming Snake and Camel cases