cannot resolve directory of all the import

Completed

So the 「Cannot resolve directory」error just pop up today (used to work normally before..)

not sure how to fix it, I've tried "go clean --modcache" and "go mod download" but still couldn't fix

below is my go env:

```

GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/chris/Library/Caches/go-build"
GOENV="/Users/chris/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/chris/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/chris/Workspace/device-sdk-go/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/nr/rc6cpjnn0753bj5sgz776tgw0000gn/T/go-build247994700=/tmp/go-build -gno-record-gcc-switches -fno-common"
```

And I have the GOROOT and GOPATH set correctly in the goland preferences, I also Enabled Go Modules (vgo) integration and set 

Vgo Executable: Project SDK

Proxy: direct

 

Let me know if any further information is needed and thanks for the help in advance.

17 comments
Comment actions Permalink

Hello Chris!

Can you please attach the contents of the go.mod file? It will also be great if you attach a few screenshots from the settings: GOPATH, Go Modules, and Build Tags & Vendoring. I also advise you to see if the path to the folder exists precisely: /Users/chris/go/pkg/mod/github.com/edgexfoundry/go-mod-core-contracts@v0.1.58/clients/

0
Comment actions Permalink

the go-mod-core-contracts@v0.1.58 did exist in my machine, below is it and the go.mod content

 

btw not sure if it's relevant, I've deleted the ~/go/pkg/sumdb directory like 2 weeks ago (was trying to replicate an error to my friend), and I think the directory is recreated by go again.

0
Comment actions Permalink

Can you tell me which version of GoLand you are using (GoLand > About GoLand)? I will also ask you to switch the view from "Project Files" to "Project" and expand the "External Libraries" section (and subfolders), then take a screenshot.

Besides, what options are available if you press Option + Enter?

0
Comment actions Permalink

so I just re-clone the repository and everything back normal again...

for your last question, I'm pretty sure though there's no option to like sync dependencies or sort import (or at least it did not auto suggest these options)

sorry for taking your time .

0
Comment actions Permalink

Thank you for taking the time to write to us, describing the situation in detail.

If the situation repeat or there are still questions, then write to us, we will be happy to help.

1
Comment actions Permalink

I am seeing a similar issue (have been for a while) and so I am going to start by adding to this ticket.

I have tried with GOPROXY set to "direct", "artifactory-proxy-for-public-and-company-repos", "artifactory-proxy-for-public-and-company-repos,direct", "off', ""
I am using go 1.14 but I also have go 1.13

Within Goland I sometimes see the terminal showing different GOPROXY values from the one I set in the preferences. At any time I can always to 'go run main.go" and it works. The resolution of symbols  and pkgs is a sad story! In terms of screenshots I don't see many differences from what Chris is seeing but I can try to attach some from my side.

 

0
Comment actions Permalink

Hello, what version of GoLand are you using? Did I understand you correctly that the same situation is observed with incorrect imports? If so, can you attach another screenshot with the External Libraries folder open (just below main.go in your case)? What options appear when you hover over an import and press Option (Alt) + Enter?

0
Comment actions Permalink

 

Yeah I have been having a lot of issues resolving public repos and/or private repos.

0
Comment actions Permalink

Thanks for the screenshots. Do you have the opportunity to upgrade to the latest version of GoLand and see if the problem persists?

 

Also, for GoLand 2019.2, you need to make sure that Go Modules support is enabled manually. To do that, go to Preferences (Settings) > Go > Go Modules (vgo). You'll also need to manually enable the vendoring mode, which can be found in the same settings path.

0
Comment actions Permalink

Hello! It doesn't look like I have any updates to go to. Please see screenshot.

 

Also I see this as soon as I re-enabled the vendoring mode manually.

It looks like it downloads it fine but it still is unable to resolve the pkg and the symbols. Trying to Synchronize the project also says "Successful" but nothing changes on the symbol resolution.

0
Comment actions Permalink

Hi, to update GoLand in your case, you need to open the Toolbox application, find the IDE there, and click "Update".

0
Comment actions Permalink

I updated through Toolbox but it so far hasn't helped. I tried tinkering with more env variables like GOSUMDB and GONOSUMDB.

 

0
Comment actions Permalink

Can you please try the following: File > Invalidates Caches / Restart?

If this has not changed anything, please send your project or its example (also attach the go.mod file) so that I can reproduce the situation.

0
Comment actions Permalink

There is something very whacky about Goland and the system env settings. There seems to be some lag in picking up the values or sometimes it never picks up the env vars from the system. At one point I even had an issue changing the GOPROXY value through Preferences.

Finally, invalidating caches and restarting worked. But at this time I have a default GOPROXY. Within a few days I may try to point it to our public facing proxy and see if it breaks. For now I am unblocked. Thanks Daniil.

0
Comment actions Permalink

This issue often comes and disappears randomly

0
Comment actions Permalink

Hello, Stephane Bruckert, please fill out a new ticket on our YouTrack. It'll be great if you include IDE logs (Help | Collect Logs and Diagnostic Data), sample project, and steps that may lead to a problem.

0
Comment actions Permalink

Is there any resolution for this? I'm having the exact same issue on

System
- macOS 10.14.6
- both GoLand 2019.3.4 and 2020.2.3
- go version go1.15.3 darwin/amd64
- GOPATH/GOROOT/Modules/etc. configured as discussed in this thread

Problem
- GoLand can't find modules that are clearly installed in $GOPATH/src for no obvious reason

Further noteworthy:
- project builds fine with go build
- When hovering over the imports GoLand states "Cannot resolve directory 'github.com'"
- There's no install/sync missing packages option in the context menu when right-clicking on the unresolved imports

0

Please sign in to leave a comment.