eja
eja

Reputation: 5329

Goland doesnt recognize module

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

Answers (2)

Parsa asadnezhad
Parsa asadnezhad

Reputation: 259

If the IDE is unable to recognize your internal packages then:

  1. Inside Settings find Go Modules
  2. Enable the Enable Go modules integration checkbox.

Upvotes: 14

shmsr
shmsr

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

Related Questions