What version of Go, VS Code & VS Code Go extension are you using?
Version Information
* Run `go version` to get version of Go from _the VS Code integrated terminal_. - go version go1.24.2 linux/amd64 * Run `gopls -v version` to get version of Gopls from _the VS Code integrated terminal_. Build info ---------- golang.org/x/tools/gopls v0.19.0-pre.2 golang.org/x/tools/gopls@v0.19.0-pre.2 h1:CUjqNCFGKHPMRZMd/tkBvtkae+eJuGNHOYsGpKxQNj4= github.com/BurntSushi/toml@v1.4.1-0.20240526193622-a339e1f7089c h1:pxW6RcqyfI9/kWtOwnv/G+AzdKuy2ZrqINhenH4HyNs= github.com/fatih/camelcase@v1.0.0 h1:hxNvNX/xYBp0ovncs8WyWZrOrpBNub/JfaMvbURyft8= github.com/fatih/gomodifytags@v1.17.1-0.20250423142747-f3939df9aa3c h1:dDSgAjoOMp8da3egfz0t2S+t8RGOpEmEXZubcGuc0Bg= github.com/fatih/structtag@v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4= github.com/google/go-cmp@v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= golang.org/x/exp/typeparams@v0.0.0-20250218142911-aa4b98e5adaa h1:Br3+0EZZohShrmVVc85znGpxw7Ca8hsUJlrdT/JQGw8= golang.org/x/mod@v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU= golang.org/x/sync@v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ= golang.org/x/telemetry@v0.0.0-20250417124945-06ef541f3fa3 h1:RXY2+rSHXvxO2Y+gKrPjYVaEoGOqh3VEXFhnWAt1Irg= golang.org/x/text@v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4= golang.org/x/tools@v0.33.1-0.20250604180551-4d89d8aef849 h1:y+3SPx7RmIoU/DCRF+k0+AhC/jvtMWEzb2m5j2j4OWA= golang.org/x/vuln@v1.1.4 h1:Ju8QsuyhX3Hk8ma3CesTbO8vfJD9EvUBgHvkxHBzj0I= honnef.co/go/tools@v0.7.0-0.dev.0.20250523013057-bbc2f4dd71ea h1:fj8r9irJSpolAGUdZBxJIRY3lLc4jH2Dt4lwnWyWwpw= mvdan.cc/gofumpt@v0.7.0 h1:bg91ttqXmi9y2xawvkuMXyvAA/1ZGJqYAEGjXuP0JXU= mvdan.cc/xurls/v2@v2.6.0 h1:3NTZpeTxYVWNSokW3MKeyVkz/j7uYXYiMtXRUfmjbgI= go: go1.24.3 * Run `code -v` or `code-insiders -v` to get version of VS Code or VS Code Insiders. - 1.100.1 91fa95bccb027ece6a968589bb1d662fa9c8e170 x64 * Check your installed extensions to get the version of the VS Code Go extension - 0.47.3 * Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > `Go: Locate Configured Go Tools` command. - # Tools Configuration ## Environment GOBIN: undefined toolsGopath: gopath: /home/firelizzard/go GOROOT: /usr/lib/go PATH: /usr/local/sbin:/usr/local/bin:/usr/bin:/opt/bin:/usr/lib/llvm/19/bin:/usr/lib/llvm/18/bin:/home/firelizzard/.local/bin:/home/firelizzard/go/bin:/home/firelizzard/go/bin:/home/firelizzard/.bin ## Tools go: /usr/bin/go: go version go1.24.2 linux/amd64 gopls: /home/firelizzard/go/bin/gopls (version: v0.19.0-pre.2 built with go: go1.24.3) gotests: /home/firelizzard/go/bin/gotests (version: v1.6.0 built with go: go1.24.1) impl: /home/firelizzard/go/bin/impl (version: v1.4.0 built with go: go1.24.1) goplay: /home/firelizzard/go/bin/goplay (version: v1.0.0 built with go: go1.24.1) dlv: /home/firelizzard/go/bin/dlv (version: v1.24.1 built with go: go1.24.1) golint: /home/firelizzard/go/bin/golint (version: v0.0.0-20241112194109-818c5a804067 built with go: go1.24.1) ## Go env Workspace Folder (hermes): /home/firelizzard/src/misc/hermes AR='ar' CC='x86_64-pc-linux-gnu-gcc' CGO_CFLAGS='-O2 -g' CGO_CPPFLAGS='' CGO_CXXFLAGS='-O2 -g' CGO_ENABLED='1' CGO_FFLAGS='-O2 -g' CGO_LDFLAGS='-O2 -g' CXX='x86_64-pc-linux-gnu-g++' GCCGO='/usr/bin/gccgo' GO111MODULE='' GOAMD64='v1' GOARCH='amd64' GOAUTH='netrc' GOBIN='' GOCACHE='/home/firelizzard/.cache/go-build' GOCACHEPROG='' GODEBUG='' GOENV='/home/firelizzard/.config/go/env' GOEXE='' GOEXPERIMENT='' GOFIPS140='off' GOFLAGS='' GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build509238208=/tmp/go-build -gno-record-gcc-switches' GOHOSTARCH='amd64' GOHOSTOS='linux' GOINSECURE='' GOMOD='/home/firelizzard/src/misc/hermes/go.mod' GOMODCACHE='/home/firelizzard/go/pkg/mod' GONOPROXY='github.com/C3Rules/Go-DTRules' GONOSUMDB='github.com/C3Rules/Go-DTRules' GOOS='linux' GOPATH='/home/firelizzard/go' GOPRIVATE='github.com/C3Rules/Go-DTRules' GOPROXY='https://proxy.golang.org,direct' GOROOT='/usr/lib/go' GOSUMDB='sum.golang.org' GOTELEMETRY='on' GOTELEMETRYDIR='/home/firelizzard/.config/go/telemetry' GOTMPDIR='' GOTOOLCHAIN='local' GOTOOLDIR='/usr/lib/go/pkg/tool/linux_amd64' GOVCS='' GOVERSION='go1.24.2' GOWORK='' PKG_CONFIG='pkg-config'
Share the Go related settings you have added/edited
settings
{
"go.useLanguageServer": true,
"go.vetFlags": [
"-composites=false"
],
// "go.formatTool": "goimports",
"go.toolsEnvVars": {
// "CGO_ENABLED": "0",
// "GOOS": "linux"
// "GOOS": "windows"
},
"go.delveConfig": {
"debugAdapter": "dlv-dap",
"hideSystemGoroutines": true,
},
"go.playground": {
"openbrowser": false,
"share": false,
"run": true
},
"go.testFlags": [
"-count=1",
// "-cpu=1",
// "-short",
// "-test.validate.full"
],
"go.testTimeout": "30m",
"go.lintOnSave": "off",
"go.testExplorer.packageDisplayMode": "nested",
"[go]": {
// "editor.formatOnSave": false,
},
"gopls": {
// "ui.documentation.hoverKind": "SynopsisDocumentation",
"ui.codelenses": {
"gc_details": true
},
"ui.diagnostic.analyses": {
"copylocks": false
}
},
"go.languageServerFlags": ["-rpc.trace"],
"go.lintTool": "golint",
"go.inlayHints.parameterNames": true,
"go.inlayHints.functionTypeParameters": true,
"go.inlayHints.constantValues": true,
"go.inlayHints.compositeLiteralFields": true,
"go.toolsManagement.autoUpdate": true,
"go.coverOnTestPackage": false,
}
Describe the bug
Gopls crashes when I interact with &cobra.Command{}
. Specifically the cobra part, I wanted to use it to insert the import.
Steps to reproduce the behavior:
- Click on "cobra".
Screenshots or recordings
The log file is in hermes.zip. I seem to be able to reproduce it just by restarting gopls. It's possible I'm running a version of gopls built from one of my CLs but gopls version
shows golang.org/x/tools/gopls v0.19.0-pre.2
so I think not.
https://github.com/user-attachments/assets/5ecc28b6-b30a-4803-81c3-7eb4f61ff457
Comment From: firelizzard18
The automated reporter didn't work. I think the log file is too big.
Comment From: firelizzard18
I ran sudo rm -rf ~/go/pkg
(some stuff in there was owned by root, probably due to running a job with docker) and rebuilt gopls. It was crashing on one particular file and after this it stopped crashing for that file, so that may have been the issue.
Comment From: adonovan
Thanks. The salient portion of the log is this:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0xc3cc4d]
goroutine 91117 gp=0xc00e431180 m=29 mp=0xc000601808 [running]:
panic({0x1104340?, 0x1e21940?})
/home/firelizzard/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.24.3.linux-amd64/src/runtime/panic.go:811 +0x168 fp=0xc014735b38 sp=0xc014735a88 pc=0x47a588
runtime.panicmem(...)
/home/firelizzard/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.24.3.linux-amd64/src/runtime/panic.go:262
runtime.sigpanic()
/home/firelizzard/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.24.3.linux-amd64/src/runtime/signal_unix.go:925 +0x359 fp=0xc014735b98 sp=0xc014735b38 pc=0x47cb99
golang.org/x/tools/internal/modindex.(*Index).Lookup(0x0, {0xc026ea2b9b, 0x5}, {0xc026ea2bb0, 0x7}, 0x0)
/home/firelizzard/go/pkg/mod/golang.org/x/tools@v0.33.1-0.20250604180551-4d89d8aef849/internal/modindex/lookup.go:71 +0x4d fp=0xc014735d90 sp=0xc014735b98 pc=0xc3cc4d
golang.org/x/tools/internal/modindex.(*Index).LookupAll(0x0, {0xc026ea2b9b, 0x5}, {0xc012163d40?, 0x10a0a40?, 0x0?})
/home/firelizzard/go/pkg/mod/golang.org/x/tools@v0.33.1-0.20250604180551-4d89d8aef849/internal/modindex/lookup.go:45 +0xc9 fp=0xc014735ee8 sp=0xc014735d90 pc=0xc3c689
golang.org/x/tools/gopls/internal/cache.(*goplsSource).resolveCacheReferences(0xc010b5ce60, 0xc018202420)
/home/firelizzard/go/pkg/mod/golang.org/x/tools/gopls@v0.19.0-pre.2/internal/cache/source.go:148 +0x1d5 fp=0xc014736200 sp=0xc014735ee8 pc=0xd757d5
golang.org/x/tools/gopls/internal/cache.(*goplsSource).ResolveReferences(0xc010b5ce60, {0x15e6c58?, 0xc018202360?}, {0xc00f31ea07?, 0x0?}, 0xc018202210)
/home/firelizzard/go/pkg/mod/golang.org/x/tools/gopls@v0.19.0-pre.2/internal/cache/source.go:70 +0x14d fp=0xc014736490 sp=0xc014736200 pc=0xd752cd
golang.org/x/tools/internal/imports.addExternalCandidates({0x15e6c58?, 0xc008d409f0?}, 0xc014736600, 0xc018202210, {0xc00f31ea07, 0x32})
/home/firelizzard/go/pkg/mod/golang.org/x/tools@v0.33.1-0.20250604180551-4d89d8aef849/internal/imports/fix.go:1193 +0xbd fp=0xc014736598 sp=0xc014736490 pc=0xc4f39d
golang.org/x/tools/internal/imports.getFixesWithSource({0x15e6c58, 0xc008d409f0}, 0xc01472ccc0, 0xc032f6c8c0, {0xc00f31ea07, 0x32}, {0xc000590750, 0xb}, 0x0, {0x15e1728, ...})
/home/firelizzard/go/pkg/mod/golang.org/x/tools@v0.33.1-0.20250604180551-4d89d8aef849/internal/imports/fix.go:654 +0x477 fp=0xc014736760 sp=0xc014736598 pc=0xc4bbb7
golang.org/x/tools/internal/imports.FixImports({0x15e6c58?, 0xc008d40600?}, {0xc00f31ea07, 0x32}, {0xc0093ff540, 0x29, 0x40}, {0xc000590750, 0xb}, 0x0, ...)
/home/firelizzard/go/pkg/mod/golang.org/x/tools@v0.33.1-0.20250604180551-4d89d8aef849/internal/imports/imports.go:88 +0x1ce fp=0xc014736818 sp=0xc014736760 pc=0xc53d8e
golang.org/x/tools/gopls/internal/golang.computeImportEdits({0x15e6c58, 0xc008d40600}, 0xc02f41e480, 0xc026d37b00, 0xc008d40960)
/home/firelizzard/go/pkg/mod/golang.org/x/tools/gopls@v0.19.0-pre.2/internal/golang/format.go:154 +0x252 fp=0xc014736938 sp=0xc014736818 pc=0xe3f872
golang.org/x/tools/gopls/internal/golang.allImportsFixes.func1({0x15e6c58?, 0xc008d40600?}, 0x93dfcb5168786c1b?)
/home/firelizzard/go/pkg/mod/golang.org/x/tools/gopls@v0.19.0-pre.2/internal/golang/format.go:120 +0x4a fp=0xc014736988 sp=0xc014736938 pc=0xe3f56a
golang.org/x/tools/gopls/internal/cache.(*importsState).runProcessEnvFunc(0xc006684a50, {0x15e6c58?, 0xc008d404e0?}, 0xc026d37b00, 0xc013fb2b70)
/home/firelizzard/go/pkg/mod/golang.org/x/tools/gopls@v0.19.0-pre.2/internal/cache/imports.go:271 +0x334 fp=0xc014736af0 sp=0xc014736988 pc=0xd4b614
golang.org/x/tools/gopls/internal/cache.(*Snapshot).RunProcessEnvFunc(...)
/home/firelizzard/go/pkg/mod/golang.org/x/tools/gopls@v0.19.0-pre.2/internal/cache/view.go:414
golang.org/x/tools/gopls/internal/golang.allImportsFixes({0x15e6c58?, 0xc008d40090?}, 0xc026d37b00, 0xc02f41e480)
/home/firelizzard/go/pkg/mod/golang.org/x/tools/gopls@v0.19.0-pre.2/internal/golang/format.go:119 +0x107 fp=0xc014736bc8 sp=0xc014736af0 pc=0xe3f3a7
golang.org/x/tools/gopls/internal/golang.(*allImportsFixesResult).init(0xc01472cc00, {0x15e6c58, 0xc008d40090}, 0xc032f6c820)
/home/firelizzard/go/pkg/mod/golang.org/x/tools/gopls@v0.19.0-pre.2/internal/golang/codeaction.go:377 +0x50 fp=0xc014736c88 sp=0xc014736bc8 pc=0xe1e2d0
golang.org/x/tools/gopls/internal/golang.lazyInit[...]({0x15e6c58, 0xc008d40090}, 0xc032f6c820)
/home/firelizzard/go/pkg/mod/golang.org/x/tools/gopls@v0.19.0-pre.2/internal/golang/codeaction.go:219 +0xa6 fp=0xc014736ce8 sp=0xc014736c88 pc=0xea6b26
golang.org/x/tools/gopls/internal/golang.quickFix({0x15e6c58?, 0xc008d40090?}, 0xc032f6c820)
/home/firelizzard/go/pkg/mod/golang.org/x/tools/gopls@v0.19.0-pre.2/internal/golang/codeaction.go:298 +0x51 fp=0xc014736e98 sp=0xc014736ce8 pc=0xe1d931
golang.org/x/tools/gopls/internal/golang.CodeActions({0x15e6c58, 0xc008d40090}, 0xc026d37b00, {0x15ebbb0, 0xc01290b200}, {{0x13fb3430?, 0xc0?}, {0x58579a?, 0x0?}}, {0xc02f41ea20, ...}, ...)
/home/firelizzard/go/pkg/mod/golang.org/x/tools/gopls@v0.19.0-pre.2/internal/golang/codeaction.go:107 +0x625 fp=0xc014737370 sp=0xc014736e98 pc=0xe1cf85
golang.org/x/tools/gopls/internal/server.(*server).CodeAction(0xc00036a300, {0x15e6c58?, 0xc0096cc690?}, 0xc00037cee0)
/home/firelizzard/go/pkg/mod/golang.org/x/tools/gopls@v0.19.0-pre.2/internal/server/code_action.go:177 +0x5a9 fp=0xc0147378e0 sp=0xc014737370 pc=0xef4d29
golang.org/x/tools/gopls/internal/protocol.serverDispatch({0x15e6c58, 0xc0096cc690}, {0x1606250, 0xc00036a300}, 0xc00b06df20, {0x15e6e50, 0xc013979a40})
/home/firelizzard/go/pkg/mod/golang.org/x/tools/gopls@v0.19.0-pre.2/internal/protocol/tsserver.go:330 +0x239d fp=0xc014737bc0 sp=0xc0147378e0 pc=0x7cdd5d
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.ServerHandler.func4({0x15e6c58, 0xc0096cc690}, 0xc00b06df20, {0x15e6e50, 0xc013979a40})
/home/firelizzard/go/pkg/mod/golang.org/x/tools/gopls@v0.19.0-pre.2/internal/protocol/protocol.go:159 +0x85 fp=0xc014737c20 sp=0xc014737bc0 pc=0xf2f345
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.handshaker.func5({0x15e6c58, 0xc0096cc690}, 0xc00b06df20, {0x15e6e50, 0xc013979a40})
/home/firelizzard/go/pkg/mod/golang.org/x/tools/gopls@v0.19.0-pre.2/internal/lsprpc/lsprpc.go:542 +0x909 fp=0xc014737ef8 sp=0xc014737c20 pc=0xf2f0a9
golang.org/x/tools/gopls/internal/protocol.Handlers.MustReplyHandler.func1({0x15e6c58, 0xc0096cc690}, 0xc01e49f488, {0x15e6e50, 0xc013979a40})
/home/firelizzard/go/pkg/mod/golang.org/x/tools@v0.33.1-0.20250604180551-4d89d8aef849/internal/jsonrpc2/handler.go:35 +0xc6 fp=0xc014737f50 sp=0xc014737ef8 pc=0x7bd606
golang.org/x/tools/gopls/internal/protocol.Handlers.AsyncHandler.func2.2()
/home/firelizzard/go/pkg/mod/golang.org/x/tools@v0.33.1-0.20250604180551-4d89d8aef849/internal/jsonrpc2/handler.go:104 +0x96 fp=0xc014737fe0 sp=0xc014737f50 pc=0x7bd436
runtime.goexit({})
/home/firelizzard/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.24.3.linux-amd64/src/runtime/asm_amd64.s:1700 +0x1 fp=0xc014737fe8 sp=0xc014737fe0 pc=0x482e61
created by golang.org/x/tools/gopls/internal/protocol.Handlers.AsyncHandler.func2 in goroutine 97
/home/firelizzard/go/pkg/mod/golang.org/x/tools@v0.33.1-0.20250604180551-4d89d8aef849/internal/jsonrpc2/handler.go:101 +0x22f