Skip to content

gopls diagnostics clear linter/Problems output #3511

Open
@kb-sp

Description

@kb-sp

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.23.0 darwin/arm64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
Build info
----------
golang.org/x/tools/gopls v0.16.1
    golang.org/x/tools/gopls@v0.16.1 h1:1hO/dCeUvjEYx3V0rVvCtOkwnpEpqS29paE+Jw4dcAc=
    github.com/BurntSushi/toml@v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
    github.com/google/go-cmp@v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
    golang.org/x/exp/typeparams@v0.0.0-20221212164502-fae10dda9338 h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH3x7MAiqGW6Y=
    golang.org/x/mod@v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0=
    golang.org/x/sync@v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
    golang.org/x/telemetry@v0.0.0-20240607193123-221703e18637 h1:3Wt8mZlbFwG8llny+t18kh7AXxyWePFycXMuVdHxnyM=
    golang.org/x/text@v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
    golang.org/x/tools@v0.22.1-0.20240628205440-9c895dd76b34 h1:Kd+Z5Pm6uwYx3T2KEkeHMHUMZxDPb/q6b1m+zEcy62c=
    golang.org/x/vuln@v1.0.4 h1:SP0mPeg2PmGCu03V+61EcQiOjmpri2XijexKdzv8Z1I=
    honnef.co/go/tools@v0.4.7 h1:9MDAWxMoSnB6QoSqiVr7P5mtkT9pOc1kSxchzPCnqJs=
    mvdan.cc/gofumpt@v0.6.0 h1:G3QvahNDmpD+Aek/bNOLrFR2XC6ZAdo62dZu65gmwGo=
    mvdan.cc/xurls/v2@v2.5.0 h1:lyBNOm8Wo71UknhUs4QTFUNNMyxy2JEIaKKo0RWOh+8=
go: go1.23.0
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
1.92.2
fee1edb8d6d72a0ddff41e5f71a671c23ed924b9
arm64
  • Check your installed extensions to get the version of the VS Code Go extension
    • v0.42.0
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.
# Tools Configuration


## Environment

GOBIN: undefined
toolsGopath: 
gopath: /Users/me/go
GOROOT: /Users/me/local/Cellar/go/1.23.0/libexec
PATH: /Users/me/google-cloud-sdk/bin:/opt/X11/bin:/opt/local/sbin:/opt/local/bin:/opt/sbin:/opt/bin:/usr/local/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin

## Tools

	go:	/Users/me/local/bin/go: go version go1.23.0 darwin/arm64

	gopls:	/Users/me/go/bin/gopls	(version: v0.16.1 built with go: go1.23.0)
	gotests:	/Users/me/go/bin/gotests	(version: v1.6.0 built with go: go1.23.0)
	gomodifytags:	/Users/me/go/bin/gomodifytags	(version: v1.16.0 built with go: go1.23.0)
	impl:	/Users/me/go/bin/impl	(version: v1.1.0 built with go: go1.23.0)
	goplay:	/Users/me/go/bin/goplay	(version: v1.0.0 built with go: go1.23.0)
	dlv:	/Users/me/go/bin/dlv	(version: v1.23.0 built with go: go1.23.0)
	golangci-lint:	/Users/me/go/bin/golangci-lint	(version: v1.60.3 built with go: go1.23.0)

## Go env

Workspace Folder (madhatter): /Users/me/go/src/github.com/MyCo/madhatter

	GO111MODULE=''
	GOARCH='arm64'
	GOBIN=''
	GOCACHE='/Users/me/Library/Caches/go-build'
	GOENV='/Users/me/Library/Application Support/go/env'
	GOEXE=''
	GOEXPERIMENT=''
	GOFLAGS=''
	GOHOSTARCH='arm64'
	GOHOSTOS='darwin'
	GOINSECURE=''
	GOMODCACHE='/Users/me/go/pkg/mod'
	GONOPROXY='github.com/MyCo,buf.build/gen/go,github.com/github-handle'
	GONOSUMDB='github.com/MyCo,buf.build/gen/go,github.com/github-handle'
	GOOS='darwin'
	GOPATH='/Users/me/go'
	GOPRIVATE='github.com/MyCo,buf.build/gen/go,github.com/github-handle'
	GOPROXY='https://proxy.golang.org,direct'
	GOROOT='/Users/me/local/Cellar/go/1.23.0/libexec'
	GOSUMDB='sum.golang.org'
	GOTMPDIR=''
	GOTOOLCHAIN='auto'
	GOTOOLDIR='/Users/me/local/Cellar/go/1.23.0/libexec/pkg/tool/darwin_arm64'
	GOVCS=''
	GOVERSION='go1.23.0'
	GODEBUG=''
	GOTELEMETRY='local'
	GOTELEMETRYDIR='/Users/me/Library/Application Support/go/telemetry'
	GCCGO='gccgo'
	GOARM64='v8.0'
	AR='ar'
	CC='cc'
	CXX='c++'
	CGO_ENABLED='0'
	GOMOD='/Users/me/go/src/github.com/MyCo/madhatter/go.mod'
	GOWORK='/Users/me/go/src/github.com/MyCo/madhatter/go.work'
	CGO_CFLAGS='-O2 -g'
	CGO_CPPFLAGS=''
	CGO_CXXFLAGS='-O2 -g'
	CGO_FFLAGS='-O2 -g'
	CGO_LDFLAGS='-O2 -g'
	PKG_CONFIG='pkg-config'
	GOGCCFLAGS='-fPIC -arch arm64 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/9z/mn1s9hm917b11k64wnvjm7nh0000gn/T/go-build2463239726=/tmp/go-build -gno-record-gcc-switches -fno-common'

Share the Go related settings you have added/edited

  "go.lintTool": "golangci-lint",
  "go.lintOnSave": "workspace",

Describe the bug

When saving a Go file, golangci-lint runs and shows warnings in the Problems pane. But when gopls diagnostics are applied, the Problems list is completely cleared of all Go issues. Other linter issues (e.g., for JSON) remain in the Problems pane.

The OUTPUT pane shows the successful run of the linter and its output, and PROBLEMS shows the errors. But when gopls.diagnosticsDelay is hit, the PROBLEMS pane is erased, and no additional output appears in the OUTPUT pane.

REALIZATION: Only golangci-lint output from the staticcheck linter seems to be affected. Other linter issues for Go or other languages remain.

Even if the staticcheck linter has become deprecated, this behavior is super confusing. ;) Additionally, our CI/CD is gated by a standalone golangci-lint run, so it's more than cosmetic.

Steps to reproduce the behavior:

Create a file that fails the staticcheck linter (in golangci-lint), save it, and gopls diagnostics will quickly clear these entries.

.golangci.yaml:

linters:
  enable:
    staticcheck

Metadata

Metadata

Assignees

Labels

NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.WaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions