Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Goland does not recognise my vendor directory with Go 1.14

When I open my Goland project, the following command is run:

/usr/local/Cellar/go/1.14/libexec/bin/go list -m -json all #gosetup

Its output is the following error:

go list -m: can't compute 'all' using the vendor directory
    (Use -mod=mod or -mod=readonly to bypass.)

Goland cannot resolve the packages I'm importing. When I build and run the project from the command line, it works fine.

My project is structured as follows:

app/
    bin/
    pkg/
    src/
        app/
            cmd/
            vendor/
            go.mod

My GOROOT is /usr/local/Cellar/go/1.14/libexec and my GOPATH is app/.

In Goland settings, under Go/GOPATH have checked the boxes for "Use GOPATH that's defined in system environment" and "Index entire GOPATH".

Under Go/Go Modules (vgo), I have checked "Enable Go Modules (vgo) integration" and "Vendoring mode"

I have just noticed when I change the GOPATH to /Users/myname/sdk/go1.13.4, the problem is solved. Could this be an issue with Homebrew or a change introduced with go 1.14 that I am not aware of?

I'm being exhaustive when describing the issue because I'm unfamiliar with Go and might be missing something obvious. Thanks!

like image 385
Youcha Avatar asked Feb 26 '20 12:02

Youcha


1 Answers

Disabling Go modules integration in Goland works for me

File->Preferences->Go->Go Modules->Enable Go modules integration

like image 193
ryuik Avatar answered Nov 05 '22 02:11

ryuik