cannot resolve directory of all the import
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.
请先登录再写评论。
I tried everything here and the only thing that helped me was removing the .idea directory.
I have the same issue, I am using go mods. I am using the workaround mentioned by "Appto
Is there a fix for this issue yet?
Env
GoLand 2021.2
Build #GO-212.4746.93, built on July 26, 2021
Thilak T, please, collect the IDE logs via Help | Collect Logs and Diagnostic Data and upload them to https://uploads.jetbrains.com/, provide its ID. Are you using GOPATH or Go Modules? Thank you.
Hello Daniil Maslov, here is the ID 2021_08_16_XYwN8iCN6nTCqMuG.
Yes, I am using GOMOD
Thanks. Unfortunately, I haven't found any suspicious in your logs. Are you using Git to version control the content inside the .idea folder? If so, could you please upload old and new .idea directories? I'll compare them to understand the underlying reasons.
I had this issue, restarting my IDE solved it.
Its a problem with .idea folder. Delete it at file explorer and reopen IDE again
SV, do you have a backup with the previous .idea directory? If so, could you please upload two versions to https://uploads.jetbrains.com/ and provide its ID? Thank you.
This is happening to me 6 out of 10 times using Idea 2021.3.2 Ultimate.
Reverting to the previous version (2021.2.4) fixes the issue for me.
I tried to clear the cache and restart, delete the .idea folder, re-initialise the project, but it would just work temporarily and the issue would come back again when re-opening the project a few more times.
I am using Go Modules, MacOS 11.6.3.
Hope this helps.
luigitni, have you renamed a project root directory or project name recently?
Daniil no I did not rename any project or root folder - just tried to remove the .idea folder or invalidate caches.
The problem started to occur when I started to use the 2021.3.2 (build IU-213.6777.52) version.
Opening the same project with 2021.2.4 (build IU-212.5712.43) has never caused the issue so far.
This is what happens in more detail:
Hope this helps
luigitni, thanks for the follow-up. Are project directories displayed in yellow color when it happened?
Daniil Thanks to you for looking into this.
No, project folders are grey (like "Extensions" in the picture above).
The project root has a blue square on the bottom right side of the icon.
luigitni, thanks. Please collect the IDE logs (step #3 in https://youtrack.jetbrains.com/issue/GO-11961#focus=Comments-27-5654986.0-0) right after it happens again and upload them to https://uploads.jetbrains.com/, then provide its ID.
Fix is trivial. Just add your Go path to module path lol. Absolutely infuriating amount of hours lost until I found this
Hi y'all,
I had the same problem with GoLand 2021.3.2. I tried every solution mentioned earlier but it did not work for me. As Sidpat said I deleted the .idea folder and re-open the project from the project folder and it is fixed. This is so disturbing, can you please fix this bug?
Saozdamar, could you please collect the IDE logs (Help | Collect Logs and Diagnostic Data) and upload them to https://uploads.jetbrains.com/ when it happens again?
Hi Daniil I just had the exact same issue occur and deleting the .idea folder and re-opening GoLand resulted in dependencies correctly being picked up. Have uploaded logs. Hopefully it helps in debugging. Upload id: 2022_06_20_SQAeyqv86RKVejTrQ3MDdq (file: goland-logs-20220620-10273814297933141429579528.zip)
Martin Madsen, thank you. Will investigate.
This issue is still happening on Build #GO-213.6777.51
My workaround is:
This is quicker than the invalidate cache and restart workaround
Roblovelock, could you please update GoLand to the latest available version to see if it helps?
go to your go.mod file and cut all the dependencies out of the file so your requires is empty and save it. Paste them back in and save. Worked for me
We did it already.
The thing is when this occurred, there is no option to sync dependencies:
GoLand 2022.1.3
Quan Tong Anh, please update GoLand to 2022.2.2, collect IDE logs (Help | Collect Logs and Diagnostic Data), upload them to https://uploads.jetbrains.com/ and provide its ID.
I had the same problem. I deleted .idea folder and this solved the problem. The issue persisted after I updated to the latest version #GO-222.4345.24
IDE doesn't know `$GOPATH/pkg/mod/<package>` instead it only knows `$GOPATH/src`. `$GOPATH/src` is no longer works when we make `go get github.com/bla/bla`
dtherhtun.cw, please make sure that Go modules integration is enabled in Preferences | Go | Go modules. If it doesn't help – upload the IDE logs (Help | Collect Logs and Diagnostic Data) to https://uploads.jetbrains.com/ and provide the ID.
Go to `Project structure` in setting and add your root folder fixed the issue
The answer from Appto solved it for me
I had the same problem with GoLand 2023.1.4
I removed the project and cloned it again. It solved the problem.
Dear Goland developers, this bug is present since 2020