Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fix GoLand not finding module dependencies ("cannot resolve...")?

I have installed my project's Go module dependencies with go build.

But GoLand is telling me it cannot resolve any of these dependencies.

How can I get GoLand to find the Go module dependencies?

like image 264
sdgluck Avatar asked May 10 '19 11:05

sdgluck


People also ask

How do I install dependencies on Go mod?

To install dependencies, use the go get command, which will also update the go. mod file automatically. Since the package is not currently used anywhere in the project, it's marked as indirect. This comment may also appear on an indirect dependency package; that is, a dependency of another dependency.

How do I sync Go dependencies?

Synchronize dependencies from the opened Go fileClick a dependency in the import section, press Alt+Enter and select Sync dependencies.

Where are Go module dependencies installed?

A Module is a collection of Go packages stored in a file tree under $GOPATH/pkg folder with a go. mod file at its root. This file defines the module's path, which is also the import path used for your project, and its dependency requirements, which are the other modules needed for a successful build.


1 Answers

Make sure that you have Go Modules support enabled.

In your preferences go to Go > Go Modules (vgo) and check "Enable Go Modules":

enter image description here

like image 99
sdgluck Avatar answered Sep 21 '22 19:09

sdgluck