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 : How to search a list of records or data structures
+6.5k Golang : Join lines with certain suffix symbol example
+36.1k Golang : Convert date or time stamp from string to time.Time type
+15k Golang : Get timezone offset from date or timestamp
+19k Golang : Execute shell command
+14.9k Golang : Accurate and reliable decimal calculations
+5.9k Golang : Build new URL for named or registered route with Gorilla webtoolkit example
+5.8k Linux/MacOSX : Search for files by filename and extension with find command
+5.8k Golang : Grab news article text and use NLP to get each paragraph's sentences
+18.1k Golang : How to get hour, minute, second from time?
+12k Golang : How to check if a string starts or ends with certain characters or words?
+13k CodeIgniter : "Fatal error: Cannot use object of type stdClass as array" message