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
+18.6k Golang : Generate thumbnails from images
+28.6k Get file path of temporary file in Go
+8.8k Golang : On lambda, anonymous, inline functions and function literals
+22.1k Golang : Repeat a character by multiple of x factor
+26.3k Golang : Calculate future date with time.Add() function
+7.4k Golang : Word limiter example
+11.4k Golang : Fix fmt.Scanf() on Windows will scan input twice problem
+19.4k Golang : Get host name or domain name from IP address
+5.7k Golang : Frobnicate or tweaking a string example
+20.5k nginx: [emerg] unknown directive "passenger_enabled"
+18.4k Golang : Read binary file into memory
+22.7k Golang : Strings to lowercase and uppercase example