Reputation: 5329
I'm having issues with Goland recognizing my imports.
So, with a basic sample structure like this
- main.go
- go.mod
- folder/something.go
imports from folder
arent recognized.
E.g. below import, within main.go
isn't valid, and Goland complains with the message Cannot resolve directory somename
import "somename/folder"
The go.mod was initialized with go mod init somename
Why is this happening? Why Goland can't resolve somename to the module that I created?
Upvotes: 2
Views: 8371
Reputation: 259
If the IDE is unable to recognize your internal packages then:
Go Modules
Enable Go modules integration
checkbox.Upvotes: 14
Reputation: 4234
Refer: JetBrains GoLand Docs: Working with Go modules
In GoLand's docs, it is mentioned that if you haven't created the Go project from the IDE itself then you have to configure it to use Go modules manually.
If you create a new Go modules project in the IDE, Go modules are already enabled. If you pulled your Go modules project from Github, you need to enable Go modules manually.
So, I assume that's why you are facing the problem. But you can follow the docs and configure your IDE correctly.
Upvotes: 16