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
+6.1k Golang : Detect face in uploaded photo like GPlus
+19.6k Golang : Accept input from user with fmt.Scanf skipped white spaces and how to fix it
+12.6k Golang : http.Get example
+23.3k Golang : minus time with Time.Add() or Time.AddDate() functions to calculate past date
+18.2k Golang : Logging with logrus
+10.9k Golang : Web routing/multiplex example
+4.8k Python : Convert(cast) bytes to string example
+5.5k Fix yum-complete-transaction error
+5.2k Golang *File points to a file or directory ?
+5.9k Java : Human readable password generator
+9.2k Golang : Terminate-stay-resident or daemonize your program?
+19.5k Golang : Archive directory with tar and gzip