-
Notifications
You must be signed in to change notification settings - Fork 796
underclared variable errrors, code compiles fine #145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@iisharankov can you please capture the gopls log following the instruction in https://github.com/golang/tools/blob/master/gopls/doc/troubleshooting.md#vs-code ? |
I believe this is what you were looking for? Apologies for the log vomit:
|
@iisharankov Thanks! This is Interestingly,
Maybe the integrated terminal is seeing a different GOPATH setup. Can you please run "Go: Current GOPATH" command from the command palette? @stamblerre Doesn't gopls send a notification or warning about misconfiguration? |
Running "GO: Current GOPATH" in the command pallet gets me
It seems it only takes the first entry then? At first I thought I set up the PATH incorrectly, but it seems fine, as:
|
How/where did you set up the GOPATH? I recently encountered issues like microsoft/vscode-go#1133 (comment). |
I set it in my ~/.zshrc profile. That's good to know that the default I explicitly set the GOPATH in settings.json by following this comment exactly: microsoft/vscode-go#1133 (comment) That seems to have fixed it, as running
and there are no longer any errors. I'll test tomorrow but it seems fixed. I'm surprised |
Marking this as closed since it was resolved. I don't know if there's anything that |
@stamblerre FYI the main culprit is the vscode didn't see the settings in @iisharankov FYI it's perfectly valid not to have |
Opening this again as I have not updated Go, VSCode, or anything else to my knowledge since the closure of this issue, so I'm not sure why there's dozens of |
@iisharankov: Can you please share your |
My bad.
|
Ah, it seems like you're opening your VS Code with your entire GOPATH ( |
Wait, so what am I doing wrong exactly? I opened a new window on VS Code and directed it only to Thanks though for the speedy updates! |
That should work - can you share the log in that case?
The query would be |
Here's a small snippet in the new workspace. Let me know also if there's a cleaner/easier way to send this that you'd prefer other than a code block.
|
This format is fine, but it is a little difficult to tell - the most useful part is the very start of the log. |
Here you go!
|
Thanks for sharing that. Looks like a |
Interesting, I'm using a FORTRAN library, so upon a How would I go about fixing this? |
I'm not very familiar with /cc @heschik for cgo guidance |
Try adding the |
Bingo! Added the following to my
Thanks for the quick replies to fix the issue! |
go version
go version go1.14.2 linux/amd64
'code -v'
Version of the VS Code Go extension
0.14.3
Go env:
Share the Go related settings you have added/edited
Run
Preferences: Open Settings (JSON)
command to open your settings.json file.Describe the bug
Red underlines under variables and functions that are clearly defined in other .go files in the same directory. Tried both upper and lowercase names. Everything compiles fine, go installs fine, go builds fine, nothing is wrong but red lines riddle every function/variable not defined in that exact file.
I reinstalled Go language support for VSCode multiple times, no lines then (obviously), but on every reinstall I get the behaviour. Reloading VSCode does not fix these false errors showing up.
Steps to reproduce the behavior:
Mak
Screenshots or recordings
Very similar to this issue, but no "@" anywhere in any path, so I couldn't find a way to fix it: microsoft/vscode-go#2858
Sometimes reloading does fix it for one file (say endpoints.go), but then main.go can't recognize the functions in endpoints.go now!
Apologies for some blocked out sections, would like to keep the repo private

Imported structs/variables from repos are detected fine. This is just local. Is my path set wrong somehow? Everything compiles fine and runs as expected, so this is just the highlighting that is having an issue. Very frustrating because my code says i have dozens of errors when I have none, and finding real ones is difficult without proper highlighting.
Is it from the two different gopaths? I can't imagne that's it.
/go
holds go libraries and repos installed, while/goworkspace
holds my projects and code i work on, just to seperate the executables and builds in/bin
.The text was updated successfully, but these errors were encountered: