patterngoModerate
"package XXX is not in GOROOT" when building a Go project
Viewed 0 times
projectpackagegorootbuildingwhennotxxx
Problem
I have a weird issue that arose when I took a break from this project. Upon starting up Golang, I'm riddled with errors when trying to run my project.
The specific error, when building one of my packages, is:
I have a folder structure as such under
and my env vars are as such:
for each of the modules (project/game/entity, project/game, project/server), I did a
When building, Goland will try to run this:
and return the error.
Can anyone help me with this issue? Kind of lost since Goland was working fine the last time I opened it. Also not even sure what direction to look at - I'm pretty new to Go and I'm not really sure what documentation to look at :\ Thank you everyone!
The specific error, when building one of my packages, is:
start.go: package project/game is not in GOROOT (C:\Go\src\project\game)I have a folder structure as such under
C:\Users\usernamego
|-src
|-project
|-game
|-entity
|-whatever.go
|-game_stuff.go
|-serverand my env vars are as such:
GOROOT=C:\Go
GOPATH=C:\Users\ketchup\gofor each of the modules (project/game/entity, project/game, project/server), I did a
git mod init.When building, Goland will try to run this:
C:\Go\bin\go.exe build -o C:\Users\ketchup\AppData\Local\Temp\___go_build_project_server.exe project/serverand return the error.
Can anyone help me with this issue? Kind of lost since Goland was working fine the last time I opened it. Also not even sure what direction to look at - I'm pretty new to Go and I'm not really sure what documentation to look at :\ Thank you everyone!
Solution
A pretty dumb conclusion (mostly on my part) but my issue came from having done
Also, my packages in GoLand were not being detected because I had Go Modules enabled in the Settings. I disabled it and GoLand was able to index the external packages and my own packages.
go mod init in each of the folders. after removing go.mod and go.dep from each of the folders I did go mod init in, I could build without issue (through terminal)Also, my packages in GoLand were not being detected because I had Go Modules enabled in the Settings. I disabled it and GoLand was able to index the external packages and my own packages.
Context
Stack Overflow Q#61845013, score: 49
Revisions (0)
No revisions yet.