vscode-go
vscode-go copied to clipboard
`go clean` can delete code
What version of Go, VS Code & VS Code Go extension are you using?
Version Information
- Run
go versionto get version of Go from the VS Code integrated terminal.- go version go1.22.0 windows/amd64
- Run
gopls -v versionto get version of Gopls from the VS Code integrated terminal.- golang.org/x/tools/gopls v0.16.1
- Run
code -vorcode-insiders -vto get version of VS Code or VS Code Insiders.- 1.92.2
- Check your installed extensions to get the version of the VS Code Go extension
- v0.42.0
Describe the bug
If you name your folder blah.go and have you code in a file called blah.go, then run go clean it will delete blah.go/blah.go.
Steps to reproduce the behavior:
- Create folder called
blah.go - Create file called
blah.go/blah.gowith contents "package main" - Create file called
blah.go/go.modwith contents "module blah go 1.22" - Run
go clean - File
blah.go/blah.gois gone.
Fix
go clean should check if folder name ends in .go before deleting a file named the same as the parent folder.
By go clean, do you mean the Go command's clean subcommand, or something else?
(In other words, the step 4 means, run go clean from the terminal?)
In other words, the step 4 means, run
go cleanfrom the terminal?
Yes, and while being in the folder blah.go.
Hi Sc00bz, I was not able to re-produce this issue, do you think this is something still happening? Do you think this is something related to VSCode?
~/Desktop/codebase/gomodifytags/vulncheck/blah.go/ [main] tree
.
├── blah.go
└── go.mod
1 directory, 2 files
~/Desktop/codebase/gomodifytags/vulncheck/blah.go/ [main] cat blah.go
package blahgo
type foo struct{}
~/Desktop/codebase/gomodifytags/vulncheck/blah.go/ [main] cat go.mod
module blah
go 1.22%
~/Desktop/codebase/gomodifytags/vulncheck/blah.go/ [main] go clean
~/Desktop/codebase/gomodifytags/vulncheck/blah.go/ [main] go1.22.0 clean
~/Desktop/codebase/gomodifytags/vulncheck/blah.go/ [main] tree
.
├── blah.go
└── go.mod
1 directory, 2 files