cannot resolve directory of all the import Follow
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:
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
Let me know if any further information is needed and thanks for the help in advance.
Please sign in to leave a comment.
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: /Usersemail@example.com/clients/
the firstname.lastname@example.org 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.
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?
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 .
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.
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.
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?
Yeah I have been having a lot of issues resolving public repos and/or private repos.
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.
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.
Hi, to update GoLand in your case, you need to open the Toolbox application, find the IDE there, and click "Update".
I updated through Toolbox but it so far hasn't helped. I tried tinkering with more env variables like GOSUMDB and GONOSUMDB.
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.
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.
This issue often comes and disappears randomly
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.
Is there any resolution for this? I'm having the exact same issue on
- 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
- GoLand can't find modules that are clearly installed in $GOPATH/src for no obvious reason
- 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
I have also tjhe same issue that forces often to download the code from the repo to solve it. Invalidating does not help at all.
The problem also happens sometimes when i switch branches.
I hope it can be solved as it renders GoLand totally disfunctional
Windows 10 latest
GoLand 2020.2.3 (but happened since 2019)
- GOPATH/GOROOT as discussed above
Found a temporary solution (Jetbrains still needs to fix this)- Delete the .idea folder in your project directory and then from within goland, open the project from that directory.
sidpat Hello, most often the error is solved in two ways:
The project contains a go.mod file:
The project doesn't contain a go.mod file
I am facing a same issue in goland 2020.1.2 version.
Unable to resolve the dependencies, tried with all above solution steps, but it didn't helped.
Nikhil Wakalkar It makes sense to update to the latest GoLand version (2020.3) if possible.
If that doesn't help, please, upload IDE logs to JetBrains Uploads and provide its name.
Thanks Daniil, it helped me to solve an issue after updating to latest version.
but not sure how it breaks all sudden though it was working in previous versions.
I assume it was an old or invalid cache, because of this, dependencies weren't recognized. Anyway, if it happens again, please, provide IDE logs, and I'll investigate deeper into it.
The same error for me :(
Build #GO-203.6682.164, built on December 29, 2020
Runtime version: 184.108.40.206+11-b1145.63 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
@Max In order to assist you, we need to know more about your project setup. Do you use Go modules? Is integration enabled? What's the Go version? Do you use vendoring? Also, log files would help. You can provide requested information here or privately via Help | Contact Support.
this happens when enable go modules (vgo) integration is checked. But I'm new to golang and I'm not sure what this setting is for...
Jangoo Enable Go Modules integration setting enables go.mod dependency management instead of GOPATH, please see: https://golang.org/ref/mod
If you are using Go modules integration, then you need to initialize go.mod file (go mod init) and then sync dependencies on any file by hover over the unresolved import and pressing Alt(Option)+Enter.
1. CLOSE your project
2. remove your `.idea` folder
3. open your project
Hi Appto, are you facing the same problem? What version of GoLand are you using (Help | Find Action | About)? Are you using Go Modules or GOPATH approach?