Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

goimports and gofmt no longer working #1344

Closed
theGeekPirate opened this issue Nov 15, 2017 · 4 comments
Closed

goimports and gofmt no longer working #1344

theGeekPirate opened this issue Nov 15, 2017 · 4 comments

Comments

@theGeekPirate
Copy link

theGeekPirate commented Nov 15, 2017

OS: Win 10
Go: 1.9.2
VS: 1.18.0
vscode-go: 0.6.67

Notes:
They both stopped working some time last night while in the middle of working on a project.
I can run goimports and gofmt manually without any issues, and go vet as well as golint are still being run on each save.
All other extensions seem to be working correctly (including those with "on save" functionality).

Paths:
Current PATH: C:\Users\user\go\bin and C:\Users\user\go\src\Go\bin are contained within it
Current GOPATH (as per the VSC extension command): C:\Users\user\go
gofmt Location: C:\tools\go\bin\gofmt.exe as well as C:\Users\user\go\src\Go\bin\gofmt.exe
goimports Location: C:\Users\user\go\bin\goimports.exe
goreturns Location: C:\Users\user\go\bin\goreturns.exe

Output:

Finished running tool: C:\Users\user\go\bin\golint.exe
Finished running tool: C:\tools\go\bin\go.exe tool vet .
Finished running tool: C:\tools\go\bin\go.exe build -i -o C:\Users\user\AppData\Local\Temp\go-code-check project\project_sub-folder

What I've Tried:

  • Adding "go.buildOnSave": "package", to my preferences (note: I have no other variables set for this extension, and had none set for it previously)
  • Updating all tools used via the CLI (using go get)
  • Updating all tools using this extension's built-in installer/updater
  • Right-click -> Format Document
  • Rebooting

What else should I be trying to correct this issue, or information can I provide for you?

Thanks!

@theGeekPirate
Copy link
Author

theGeekPirate commented Nov 15, 2017

Specifying "go.formatTool": "gofmt", does seem to work, while setting it to "goimports" or "goreturns" does not.

I should probably reiterate that both goimports and goreturns do work when run manually (although I don't use goreturns normally, I can confirm it at least populates my imports correctly, which is all I really care about besides the formatting).

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Nov 17, 2017

The fact that gofmt works but the other 2 dont are puzzling to me.
All the 3 tools use the same code path in the extension

Can you try setting go.useDiffForFormatting to false? We noticed that goreturns sometimes returns diff data in an incompatible format.

We did have an issue with formatting (#1333), but that was for folks on 1.19 Insiders but you are on 1.18

@theGeekPirate
Copy link
Author

@ramya-rao-a That seems to have fixed it!

@ramya-rao-a
Copy link
Contributor

Great, I am not sure of the root cause here though as to why goreturns and goimports do not return anything when run with -d

Here is the upstream issue if you are interested: sqs/goreturns#28

Closing this issue as the workaround works for you.

Happy Coding!

@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants