11

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!

Youcha
  • 1,534
  • 2
  • 16
  • 30
  • Saves my day. Now the Goland 2020.1 is out and has automatic vendoring mode support, https://www.jetbrains.com/go/whatsnew/#go-114-support – wanghq May 26 '20 at 18:00

2 Answers2

14

This is a known problem with Go Modules and vendoring support due to tooling change in Go 1.14.

As such, please try the EAP version of the IDE, https://jetbrains.com/go/nextversion, which contains a fix for this.

We are tracking this under https://youtrack.jetbrains.com/issue/GO-8855 and thinking about backporting this to the 2019.3 release cycle.

dlsniper
  • 7,188
  • 1
  • 35
  • 44
  • Since i’m using the Jetbrains Toolbox, it was as simple as enabling EAP, i presume this will allow me to go back to stable releases in the future. – Ash Feb 28 '20 at 00:04
  • Yes, that's correct. You can use the EAP version in parallel with the stable version. You can read here: https://blog.jetbrains.com/go/tag/2020-1/ about what features to expect from 2020.1 – dlsniper Feb 28 '20 at 05:55
  • Is there a workaround for older versions like 2019.1? My license expired and can't upgrade to latest version. – Wei Huang Aug 05 '20 at 12:40
  • No, sorry. Please reach out to the Sales team and maybe they'll be able to help you out with the upgrade to 2020.2. – dlsniper Aug 05 '20 at 19:15
3

Disabling Go modules integration in Goland works for me

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

ryuik
  • 69
  • 4