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
+3.8k Golang : Frobnicate or tweaking a string example
+6.9k Golang : Generate random Chinese, Japanese, Korean and other runes
+6.4k Swift : Convert (cast) String to Float
+19.8k Golang : Get ASCII code from a key press(cross-platform) example
+12.7k Golang : How to get Unix file descriptor for console and file
+7.5k Golang : Format strings to SEO friendly URL example
+17.6k Golang : How to get struct tag and use field name to retrieve data?
+24k Golang : Find files by name - cross platform example
+13.7k Golang : Execute terminal command to remote machine example
+19.2k Golang : Join arrays or slices example
+14.7k Golang : Put UTF8 text on OpenCV video capture image frame
+3.5k HTTP common errors and their meaning explained