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
+24.8k Golang : missing Mercurial command
+24.1k Golang : Convert long hexadecimal with strconv.ParseUint example
+10.8k How to tell if a binary(executable) file or web application is built with Golang?
+18.8k Golang : Compare floating-point numbers
+4.3k Golang : Convert lines of string into list for delete and insert operation
+7.8k Golang : How to join strings?
+7.9k Golang : Accept any number of function arguments with three dots(...)
+4.6k Javascript : How to loop over and parse JSON data?
+7.1k Javascript : Put image into Chrome browser's console
+5.7k Golang : Combine slices of complex numbers and operation example
+17.4k Golang : Display list of time zones with GMT
+15.7k Golang : Merge video(OpenCV) and audio(PortAudio) into a mp4 file