You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.
This is the most annoying feature of go compiler –it fails when source files contain unused imports:
drivers/azurenew/azurenew.go:4: imported and not used: "errors"
drivers/azurenew/azurenew.go:6: imported and not used: "os"
drivers/azurenew/azurenew.go:7: imported and not used: "os/exec"
drivers/azurenew/azurenew.go:8: imported and not used: "strings"
Every time I refactor code I find myself going through the compile-edit-compile-edit... loop and I think vscode can help here.
We just need to highlight imports as syntax errors and say "imported and not used". Not sure if doable but that'd make thinks a great deal easier. Maybe goimports can help. https://godoc.org/golang.org/x/tools/cmd/goimports
The text was updated successfully, but these errors were encountered:
The "format" command will run whichever of gofmt, goimports or goreturns you choose via go.formatTool settings. These build on one another so goimports does everything gofmt does plus more and goreturns does everything goimports does plus more.
For what you want here, you want at least goimports which will automatically add/remove imports as needed by your code.
Out of the box, assuming you've installed all the tools (see this comment), running Format Document should fix up imports for you.
#14 is tracking adding an option to enabled format-on-save so that you don't even need to do a separate action to get formatting + imports fixup.
Given all that, I'm not sure there's anything additional to address here. If you think there is something beyond what's tracked in those other issues though feel free to reopen.
This is the most annoying feature of go compiler –it fails when source files contain unused imports:
Every time I refactor code I find myself going through the compile-edit-compile-edit... loop and I think vscode can help here.
We just need to highlight imports as syntax errors and say "imported and not used". Not sure if doable but that'd make thinks a great deal easier. Maybe goimports can help. https://godoc.org/golang.org/x/tools/cmd/goimports
The text was updated successfully, but these errors were encountered: