Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/gopls: intellisense dropdown not working with log/slog package in VSCode #71866

Open
soypat opened this issue Feb 20, 2025 · 3 comments
Labels
BugReport Issues describing a possible bug in the Go implementation. gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@soypat
Copy link

soypat commented Feb 20, 2025

gopls version

Build info

golang.org/x/tools/gopls v0.18.0
golang.org/x/tools/gopls@v0.18.0 h1:oBmnrmi0Uk7Ea+ZPK16BdcjnpEJX8ciBCSp9S90GULo=
github.com/BurntSushi/toml@v1.4.1-0.20240526193622-a339e1f7089c h1:pxW6RcqyfI9/kWtOwnv/G+AzdKuy2ZrqINhenH4HyNs=
github.com/google/go-cmp@v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
golang.org/x/exp/typeparams@v0.0.0-20241210194714-1829a127f884 h1:1xaZTydL5Gsg78QharTwKfA9FY9CZ1VQj6D/AZEvHR0=
golang.org/x/mod@v0.23.0 h1:Zb7khfcRGKk+kqfxFaP5tZqCnDZMjC5VtUBs87Hr6QM=
golang.org/x/sync@v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
golang.org/x/telemetry@v0.0.0-20241220003058-cc96b6e0d3d9 h1:L2k9GUV2TpQKVRGMjN94qfUMgUwOFimSQ6gipyJIjKw=
golang.org/x/text@v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
golang.org/x/tools@v0.30.1-0.20250220174815-31e3bb2b8fd1 h1:4+it9JYqVd2wIAapscAb5mUAI1yHY0u4B4idYPigWeE=
golang.org/x/vuln@v1.1.3 h1:NPGnvPOTgnjBc9HTaUx+nj+EaUYxl5SJOWqaDYGaFYw=
honnef.co/go/tools@v0.5.1 h1:4bH5o3b5ZULQ4UrBmP+63W9r7qIkqJClEA9ko5YKx+I=
mvdan.cc/gofumpt@v0.7.0 h1:bg91ttqXmi9y2xawvkuMXyvAA/1ZGJqYAEGjXuP0JXU=
mvdan.cc/xurls/v2@v2.5.0 h1:lyBNOm8Wo71UknhUs4QTFUNNMyxy2JEIaKKo0RWOh+8=
go: go1.24.0

go env

$ go env
AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/pato/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/pato/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build4240856941=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/pato/Documents/src/tg/lneto/go.mod'
GOMODCACHE='/home/pato/go/pkg/mod'
GONOPROXY='gitlab.com/NovoSpace'
GONOSUMDB='gitlab.com/NovoSpace'
GOOS='linux'
GOPATH='/home/pato/go'
GOPRIVATE='gitlab.com/NovoSpace'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/pato/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.24.0'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

Happened with both Go 1.23.6 installed via Arch package repository and Go 1.24.0 installed via go.dev instructions.

Open any project, start typing in slog.* where slog project used and imported.

What did you see happen?

No intellisense display of available identifiers in log/slog package.

What did you expect to see?

All identifiers being displayed. Happens with every other single Go package except unsafe (which even then exposes identifiers as "words"), which I suppose is expected. log package intellisense works.

Editor and settings

{
"workbench.sideBar.location": "right",
"workbench.colorTheme": "GitHub Dark High Contrast",
"explorer.confirmDelete": false,
"gopls":{
"verboseOutput": true,
},
}

Logs

The instructions to enable logging and the serve flag are unclear. I enabled verbose output:

2025-02-20 17:36:47.291 [info] Try to start language server - activation (enabled: true)
2025-02-20 17:36:47.348 [info] Running language server gopls(v0.18.0/go1.24.0)
2025-02-20 17:39:24.291 [info] Try to start language server - activation (enabled: true)
2025-02-20 17:39:24.346 [info] Running language server gopls(v0.18.0/go1.24.0)
2025-02-20 17:39:37.181 [info] Running checks...
2025-02-20 17:39:37.181 [info] Starting linting the current package at /home/pato/Documents/src/tg/lneto/examples/stack
2025-02-20 17:39:37.274 [info] /home/pato/Documents/src/tg/lneto/examples/stack>Finished running tool: /home/pato/go/bin/staticcheck
2025-02-20 17:39:37.274 [info] /home/pato/Documents/src/tg/lneto/examples/stack/main.go:44:12 syntax error: unexpected newline in argument list; possibly missing comma or )
2025-02-20 17:39:37.274 [info] /home/pato/Documents/src/tg/lneto/examples/stack/main.go:45:74 syntax error: unexpected ) after top level declaration
2025-02-20 17:39:37.274 [info] /home/pato/Documents/src/tg/lneto/examples/stack/main.go:60:2 syntax error: non-declaration statement outside function body (compile)
2025-02-20 17:39:37.274 [info] 
2025-02-20 17:39:41.281 [info] Running checks...
2025-02-20 17:39:41.282 [info] Starting linting the current package at /home/pato/Documents/src/tg/lneto/examples/stack
2025-02-20 17:39:41.364 [info] /home/pato/Documents/src/tg/lneto/examples/stack>Finished running tool: /home/pato/go/bin/staticcheck
2025-02-20 17:39:41.364 [info] /home/pato/Documents/src/tg/lneto/examples/stack/main.go:44:2 not enough arguments in call to slog.New
2025-02-20 17:39:41.364 [info] 
@soypat soypat added gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. labels Feb 20, 2025
@gopherbot gopherbot added this to the Unreleased milestone Feb 20, 2025
@gabyhelp gabyhelp added the BugReport Issues describing a possible bug in the Go implementation. label Feb 20, 2025
@adonovan
Copy link
Member

Very strange. One thought: what version of Go appears in your go.mod file? (Or: hover over the package declaration in your current source file and look for "Language version".) If it is less than go1.21 then completion won't offer log/slog. I doubt that can be the explanation though, because you mentioned that the file already imports the slog package.

@adonovan adonovan added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Feb 21, 2025
@soypat
Copy link
Author

soypat commented Feb 22, 2025

Yes it was the go.mod file! I changed go 1.20 to go 1.21 and now intellisense works. It's odd because the program previously compiled fine and outputs slog records...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BugReport Issues describing a possible bug in the Go implementation. gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants