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
+5.7k Golang : Function as an argument type example
+7.1k Golang : How to convert strange string to JSON with json.MarshalIndent
+27k Golang : dial tcp: too many colons in address
+7.1k Golang : Process json data with Jason package
+13.9k Golang : Convert IP version 6 address to integer or decimal number
+11.3k Golang : Display a text file line by line with line number example
+7k Golang : Accessing dataframe-go element by row, column and name example
+5.7k Golang : Use NLP to get sentences for each paragraph example
+18.6k Golang : How to make function callback or pass value from function as parameter?
+39.6k Golang : Convert to io.ReadSeeker type
+11.7k Golang : Detect user location with HTML5 geo-location
+28.1k Get file path of temporary file in Go