Intellij shows all modules in go.mod as undefined
Completed
I create a new project from existing sources. I set the GOROOT for the project. GOPATH is set correctly. I've run go get and go mod tidy on the project. Running go build from the command line on one of the main.go files in the cmd/ directory builds a binary. (There are multiple main.go files in this project.)
Intellij shows every module in go.mod as an Unresolved Dependency. In .go files Intellij shows all imports that are not part of the Go installation as unresolved directories. This is on Windows.
Why is Intellij showing these errors when this project is structured properly and builds properly from the command line?
Please sign in to leave a comment.
Is Go modules integration enabled via File | Settings | Languages & Frameworks | Go | Go Modules? What options are available if you press Alt+Enter on unresolved imports inside Go files?
Enabling go modules integration solved this. Modules integration should be enabled when you create a new project from source code that has a go.mod file in it.
Thanks for the update. Go modules integration will be enabled automatically since the 2022.1 update.
I downloaded GoLand 2022.1.2 (Build #GO-221.5787.30, built on May 31, 2022) today and the Go modules integration was not enabled automatically.
Spencer Tuft, can you reproduce it if you delete .idea directory in the project root? Most likely, .idea directory exists before you've opened the project in the IDE and it inherits previous settings.
Daniil, you're correct. New projects appear to have the Go modules integration setting enabled by default. Thanks!