Closed mellowdrifter closed 5 years ago
Thanks for reporting @mellowdrifter
Let's first try the below on your local setup, make sure that works before moving to WSL
Go: Current GOPATH
result in a notification with a result or throws an error? This will help in determining if the extension is activated or notView
, select Output
. In the output panel that appears, select "go" from the drop down at the top right corner. Save your Go file. Do you see anything being logged in the output channel? you should be able to see build, lint and vet processes being triggered.Heya. These are the results running locally.
Does running the command Go: Current GOPATH result in a notification with a result or throws an error? This will help in determining if the extension is activated or not Yes. Output shown is C:\Users\mellowd\go is the current GOPATH. (correct)
From the menu View, select Output. In the output panel that appears, select "go" from the drop down at the top right corner. Save your Go file. Do you see anything being logged in the output channel? you should be able to see build, lint and vet processes being triggered. Yes I see output, but the outputs seem to be errors in other package, not my new test file I'm running. My test file is simply a hello world with no imports. I'm expecting goimports to add "fmt"
The actual window says things like this: "Starting linting the current package at c:\Users\mellowd\Desktop Starting "go vet" under the folder c:\Users\mellowd\Desktop Starting building the current package at c:\Users\mellowd\Desktop Not able to determine import path of current package by using cwd: c:\Users\mellowd\Desktop and Go workspace: C:\Users\mellowd\Desktop>Finished running tool: C:\Users\mellowd\go\bin\golint.exe
C:\Users\mellowd\Desktop>Finished running tool: C:\Go\bin\go.exe build -i -o C:\Users\mellowd\AppData\Local\Temp\vscode-gotPQOoC\go-code-check .
C:\Users\mellowd\Desktop>Finished running tool: C:\Go\bin\go.exe vet ./... C:\Users\mellowd\Desktop\mvoe\mellowdrifter\bgp_infrastructure\sqlproto\sqlproto.go:10: cannot find package "github.com/go-sql-driver/mysql" in any of: C:\Users\mellowd\Desktop\mvoe\mellowdrifter\gopl\ch2\cu\main.go:8: cannot find package "github.com/mellowdrifter/gopl/ch2/conversions" in any"
So this is interesting. I save test.go to my desktop. On the desktop I have a backup of some of my other projects in the mvoe folder. When I clicked save on test.go, the output above could be seen. So as a test I created a new folder on the desktop, moved test.go to that folder, and Goimports now worked. Odd because test.go and the above files were not even in the same path to begin with.
Can you share any Go related settings you might have added/edited? You can see your settings after running the command `Preferences: Open Settings(JSON)
Sure, not many: { "files.autoSave": "afterDelay", "editor.fontSize": 16, "files.autoSaveDelay": 10000, "workbench.colorTheme": "Atom One Dark", "editor.minimap.enabled": false }
Looks like you are working outside your GOPATH, are you using modules?
I am guessing, the below is your folder structure
In this case, when you open test.go
, the extension tries to build the package to which the file belongs to. First, the extension tries to figure out the import path to the current package. Since you are not under GOPATH, it can't figure out the import path and so falls back to using go build .
in the current folder which is the desktop in your case.
I believe if you ran go build .
yourself in your desktop you would get the same errors.
Does moving test.go
to its own file solve all other problems you have?
No modules no. And yes this was just a test on a file locally not in my gopath.
And yes, moving that file to it's own directory caused it to work.
However going back to the initial WSL issue, the problem still exists. I'm going to run the same commands you requested in a WSL mounted project.
Does running the command Go: Current GOPATH result in a notification with a result or throws an error? This will help in determining if the extension is activated or not This works correctly - /home/mellowd/go is the current GOPATH.
From the menu View, select Output. In the output panel that appears, select "go" from the drop down at the top right corner. Save your Go file. Do you see anything being logged in the output channel? you should be able to see build, lint and vet processes being triggered. In this test I've removed the "fmt" import which I use in the file. When I save this is what I see in the output window:
Starting linting the current package at /home/mellowd/go/src/github.com/mellowdrifter/bgpstuff.net Starting "go vet" under the folder /home/mellowd/go/src/github.com/mellowdrifter/bgpstuff.net Starting building the current package at /home/mellowd/go/src/github.com/mellowdrifter/bgpstuff.net /home/mellowd/go/src/github.com/mellowdrifter/bgpstuff.net>Finished running tool: /home/mellowd/go/bin/golint
/home/mellowd/go/src/github.com/mellowdrifter/bgpstuff.net>Finished running tool: /usr/bin/go vet ./... /home/mellowd/go/src/github.com/mellowdrifter/bgpstuff.net/handlers.go:126: undefined: fmt /home/mellowd/go/src/github.com/mellowdrifter/bgpstuff.net/handlers.go:242: undefined: fmt /home/mellowd/go/src/github.com/mellowdrifter/bgpstuff.net/handlers.go:292: undefined: fmt /home/mellowd/go/src/github.com/mellowdrifter/bgpstuff.net/handlers.go:321: undefined: fmt /home/mellowd/go/src/github.com/mellowdrifter/bgpstuff.net/handlers.go:413: undefined: fmt /home/mellowd/go/src/github.com/mellowdrifter/bgpstuff.net/handlers.go:424: undefined: fmt /home/mellowd/go/src/github.com/mellowdrifter/bgpstuff.net/handlers.go:427: undefined: fmt /home/mellowd/go/src/github.com/mellowdrifter/bgpstuff.net/handlers.go:457: undefined: fmt /home/mellowd/go/src/github.com/mellowdrifter/bgpstuff.net/handlers.go:466: undefined: fmt /home/mellowd/go/src/github.com/mellowdrifter/bgpstuff.net/handlers.go:476: undefined: fmt /home/mellowd/go/src/github.com/mellowdrifter/bgpstuff.net/handlers.go:476: too many error
Can you share any Go related settings you might have added/edited? You can see your settings after running the command `Preferences: Open Settings(JSON)
Unchanged from before, but pasting here to make it easier: { "files.autoSave": "afterDelay", "editor.fontSize": 16, "files.autoSaveDelay": 10000, "workbench.colorTheme": "Atom One Dark", "editor.minimap.enabled": false, "go.autocompleteUnimportedPackages": true, "remote.SSH.showLoginTerminal": true }
From the logs, you can see that build, lint and vet processes have started, but only lint and vet processes completed. Is that a complete copy of the logs? It could be that you copied before go build
got a chance to complete.
Is /home/mellowd/go/src/github.com/mellowdrifter/bgpstuff.net/handlers.go
the file you edited? If so, then the vet process is able to catch the error. Do you see anything in the Problems view? Select View
from the menu and then Problems
That's the complete copy yes. The last error is the 'too many errors' line.
handlers.go is the file yes. In problems I see the following:
Ok, so in your WSL set up what we know is the below
Your initial concern was that goimports/goreturns are not being run on on file save. These tools are run as part of the formatting process. Can you try formatting the file manually and see if that works? Right-click on your doc and choose "Format Document"
Interesting, running format correctly formatted the doc. "fmt" was imported and it corrected the indentation of a few of my forced errors.
Problem output shows "no problems have been detected in the workspace so far"
But if I delete "fmt" and click save directly, the same errors :/
Considering running 'format' seems to do the required thing, I've changed this setting to format on save. This seems to work. However I don't recall ever turning this off
This could be a problem with the timeout that gets kicked in for the format on save feature.
Can you try tweaking the editor.formatOnSaveTimeout
setting?
This issue has been closed automatically because it needs more information and has not had recent activity. Thank you for your contributions.
Moved from a linux environment to a Windows environment using WSL.
Go extension was working fine for a few weeks. Three days ago is just stopped working. When I save a Go file, Goimports or Goreturns no longer runs at all. It doesn't even attempt to run.
Running these from the terminal directly works fine. I tried uninstalling and reinstall the extenstion. I tried uninstalling vscode, deleting all cached settings, reinstalling both vscode and the extenstion. But no difference. I tried upgrading from Go 1.10 to 1.12 and reinstalling the extenstion again, but no difference.
Tried switching to coding locally instead of WSL, and the same thing happens
It just refuses to do anything.
VS Code 1.37.1 Go extension 0.11.4