vscode-go
vscode-go copied to clipboard
x/tools/gopls: renaming a file breaks code completion when letter capitalization changes
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.- go1.22.0 windows/amd64
- Run
gopls -v versionto get version of Gopls from the VS Code integrated terminal.
Build info
----------
golang.org/x/tools/gopls v0.15.3
golang.org/x/tools/[email protected] h1:zbdOidFrPTc8Bx0YrN5QKgJ0zCjyGi0L27sKQ/bDG5o=
github.com/BurntSushi/[email protected] h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
github.com/google/[email protected] h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
golang.org/x/exp/[email protected] h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH3x7MAiqGW6Y=
golang.org/x/[email protected] h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8=
golang.org/x/[email protected] h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
golang.org/x/[email protected] h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
golang.org/x/[email protected] h1:vcVnuftN4J4UKLRcgetjzfU9FjjgXUUYUc3JhFplgV4=
golang.org/x/[email protected] h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/[email protected] h1:uH9jJYgeLCvblH0S+03kFO0qUDxRkbLRLFiKVVDl7ak=
golang.org/x/[email protected] h1:KUas02EjQK5LTuIx1OylBQdKKZ9jeugs+HiqO5HormU=
honnef.co/go/[email protected] h1:oFEHCKeID7to/3autwsWfnuv69j3NsfcXbvJKuIcep8=
mvdan.cc/[email protected] h1:G3QvahNDmpD+Aek/bNOLrFR2XC6ZAdo62dZu65gmwGo=
mvdan.cc/xurls/[email protected] h1:lyBNOm8Wo71UknhUs4QTFUNNMyxy2JEIaKKo0RWOh+8=
go: go1.22.0
- Run
code -vorcode-insiders -vto get version of VS Code or VS Code Insiders.- 1.89.1 dc96b837cf6bb4af9cd736aa3af08cf8279f7685 x64
- Check your installed extensions to get the version of the VS Code Go extension
- v0.41.4
- Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) >
Go: Locate Configured Go Toolscommand.
# Tools Configuration
## Environment
GOBIN: undefined
toolsGopath:
gopath: C:\Users\hinst\go
GOROOT: C:\Program Files\Go
PATH: C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\hinst\AppData\Roaming\nvm;C:\Program Files\nodejs;C:\Program Files\dotnet\;C:\FPC\3.2.2\bin\i386-Win32;C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin;C:\Library\Swift-development\bin;C:\Library\icu-69.1\usr\bin;C:\Program Files\PowerShell\7\;C:\Program Files\Go\bin;C:\Program Files\usbipd-win\;C:\Program Files\Docker\Docker\resources\bin;C:\Program Files\Git\cmd;C:\HaxeToolkit\haxe;C:\Users\hinst\scoop\shims;C:\Users\hinst\AppData\Local\Programs\Python\Launcher\;C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.2\plugins\maven\lib\maven3\bin;C:\Users\hinst\.cargo\bin;C:\Users\hinst\AppData\Local\Yarn\bin;C:\Users\hinst\AppData\Local\Microsoft\WindowsApps;C:\Users\hinst\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\hinst\AppData\Roaming\npm;C:\Program Files (x86)\Sophos\Sophos SSL VPN Client\bin;C:\Users\hinst\AppData\Roaming\nvm;C:\Users\hinst\go\bin;C:\Users\hinst\AppData\Roaming\nvm;C:\Program Files\nodejs;C:\Users\hinst\go\bin;C:\Users\hinst\.azure-kubectl;C:\Users\hinst\.azure-kubelogin;C:\Users\hinst\.deno\bin;C:\Users\hinst\go\bin;C:\Users\hinst\AppData\Local\JetBrains\Toolbox\scripts;
## Tools
go: C:\Program Files\Go\bin\go.exe: go version go1.22.0 windows/amd64
gopls: C:\Users\hinst\go\bin\gopls.exe (version: v0.15.3 built with go: go1.22.0)
gotests: C:\Users\hinst\go\bin\gotests.exe (version: v1.6.0 built with go: go1.22.0)
gomodifytags: C:\Users\hinst\go\bin\gomodifytags.exe (version: v1.16.0 built with go: go1.22.0)
impl: C:\Users\hinst\go\bin\impl.exe (version: v1.1.0 built with go: go1.22.0)
goplay: C:\Users\hinst\go\bin\goplay.exe (version: v1.0.0 built with go: go1.22.0)
dlv: C:\Users\hinst\go\bin\dlv.exe (version: v1.22.0 built with go: go1.22.0)
staticcheck: C:\Users\hinst\go\bin\staticcheck.exe (version: v0.4.6 built with go: go1.22.0)
## Go env
Workspace Folder (MassFood_2D): c:\Dev\MassFood_2D
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\hinst\AppData\Local\go-build
set GOENV=C:\Users\hinst\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\hinst\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\hinst\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.22.0
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=0
set GOMOD=c:\Dev\MassFood_2D\go.mod
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\hinst\AppData\Local\Temp\go-build2771098946=/tmp/go-build -gno-record-gcc-switches
Share the Go related settings you have added/edited
Run Preferences: Open Settings (JSON) command to open your settings.json file.
Share all the settings with the go. or ["go"] or gopls prefixes.
"go.toolsManagement.autoUpdate": true
Describe the bug
Renaming golang source file in the project breaks code completion in that file, in cases when only letter capitalization got changed.
Expected behavior: there are no errors Actual behavior: there are errors
Steps to reproduce the behavior:
- Create an empty folder and open it in VSCode
- Create a file named
main.go - Paste
package mainfunc main() {}
- Rename the file a few times:
6.
Main.go7.maiN.go8.application.go9.Application.go10.aPplication.go11. ...and so on - Observe errors:
- No packages found for open file C:\Dev\repro\application.go
- case-insensitive file name collision: "maiN.go" and "main.go"
Screenshots or recordings
@hinst , can you close all the files and restart to check if issues persists?
I got the same problem in my repository, after I try to re-name my folder and package case,
half of my file showing case-insensitive import collision, when I trying to switch back to old name, the other half showing the same error,
I need to re-init entire mod to fix the problem .
Having this exact issue. Three other files finally got fixed and are no longer erroring. One file is stuck in this state. I even tried uninstalling/reinstalling go on my windows 11 installation. Have also restarted vscode, my whole pc, renaming the file multiple times, and deleting go.mod+go.sum and reinstalling all packages from scratch, updating go version. The project does build fine. Will probably have to just rename the file to something else thats less descriptive/accurate.
not the best solution , but you can delete your go.mod and go.sum, rerun go mod init <your-package-name> and finally run go mod tidy and you should be good to go. Also re-load your IDE
This happens to me aswell. It makes renaming files very annoying....
not the best solution , but you can delete your go.mod and go.sum, rerun
go mod init <your-package-name>and finally rungo mod tidyand you should be good to go. Also re-load your IDE
After testing, this is the best solution to the problem. You can even paste the original go.mod content back after running go mod init, and it will still work.
Same Issue. It's really unbelievable to dismantle the entire project's infrastructure just to rename a file.
I found two methods based on the same principle:
Method 1:
- Open
C:\Users\<USERNAME>\AppData\Roaming\Code\User\workspaceStorage. - Locate your current workspace (usually identified by the modified time).
- Delete the workspace folder!
Method 2:
- Copy your project to another location on the disk.
Both methods clear the workspace cache of incorrect file names, but you'll need to reconfigure your workspace-specific settings and enabled extensions afterward.
This finding indicates it's a vscode/vscode-go issue. However, due to limited details from the extension, we can't address the bug directly without examining the source code. As users, our only option is to reset all of the workspace data to its initial state.