"Cannot find declaration to go to" for Go files
Answered
I'm unable to go to declaration of any variable or function in golang. Can someone please help?
I've tried below steps, but to no vail:
- Remove *.iml files in .idea > didn’t work
- Enable go plugin -> didn’t work
- Checked Settings/Preferences | Editor | File Types -> *.go already not in registered text patterns

Please sign in to leave a comment.
Could you check if:
⌘ + ,on macOS orCtrl + Alt + Son Win/Linux) > Languages & Frameworks > GOROOT:⌘ + ,on macOS orCtrl + Alt + Son Win/Linux) >Languages & Frameworks > GOPATH:⌘ + ,on macOS orCtrl + Alt + Son Win/Linux) > Editor > File Types:If you still cannot go to any variable/method declaration, if possible please provide your project sample so that we can reproduce the issue on our side. Also, your IDE log file (Help > Collect Logs and Diagnostic Data).
You can upload both the zipped project folder and log files here: https://uploads.jetbrains.com, and provide the uploaded file ID.
I have the same issue. I've followed all of the steps above. It seems to lack a certain “intelli”gence when it comes to understanding Go projects.
Ed Randall
Could you please share a screenshot or screen recording showing the entire IDE window (especially project tree in a project tool window and file in the editor) when this issue occurs? Do you have the Go plugin installed and enabled? If possible, please share a sample project to try and reproduce the issue on our end?
Also, please restart the IDE, reproduce the issue and share your IDE logs (Help > Collect Logs and Diagnostic Data). They contain information about your environment and possibly some exceptions/errors related to the issue.
You can zip all of those files and upload them securely here: https://uploads.jetbrains.com, just provide the uploaded file ID.
Thanks - have solved this now. It turned out to be an internal proxy problem. Solution:
a) Tick “Enable Go modules integration”
b) Environment: GOPROXY=https://atrifactory.ourdomain.com/artifactory/api/go/goproxy (this is the address of our internal artifact repository)
c) Possibly also set HTTP_PROXY, HTTPS_PROXY and NO_PROXY environment variables (depending on corp. requirements)
The way to test/experiment & find the configuration needed was by running:
Until HTTP_PROXY, HTTPS_PROXY, NO_PROXY and GOPROXY were correct, each dependency URL was printed with a “Bad Gateway” message.