Skip to content

goLint: golangci-lint v2 can't handle diagnostic errors correctly without run.relative-path-mode: wd #3750

Closed
@logica0419

Description

@logica0419

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.1 linux/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
    • golang.org/x/tools/gopls v0.18.1
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
    • 1.98.2
  • Check your installed extensions to get the version of the VS Code Go extension
    • 0.46.1
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.
# Tools Configuration


## Environment

GOBIN: undefined
toolsGopath: 
gopath: /home/logica/go
GOROOT: /usr/local/go
PATH: /home/logica/.vscode-server/bin/ddc367ed5c8936efe395cffeec279b04ffd7db78/bin/remote-cli:/home/linuxbrew/.linuxbrew/opt/clang-format/bin:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Program Files/Common Files/Oracle/Java/javapath:/mnt/c/Program Files (x86)/Common Files/Intel/Shared Libraries/redist/intel64/compiler:/mnt/c/WINDOWS/System32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Program Files/MATLAB/R2022a/bin:/mnt/c/Program Files (x86)/dotnet/:/mnt/c/Program Files/dotnet/:/mnt/c/Program Files (x86)/Tailscale IPN/:/mnt/c/Program Files/Tailscale/:/mnt/c/Program Files (x86)/GnuPG/bin:/mnt/c/Program Files/NVIDIA Corporation/NVIDIA app/NvDLISR:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Users/Takuto/AppData/Local/Microsoft/WindowsApps:/mnt/c/Program Files/Java/jdk-11.0.12/bin:/mnt/c/Users/Takuto/AppData/Local/Programs/Microsoft VS Code/bin:/snap/bin:/usr/local/go/bin:/home/logica/go/bin:/home/logica/.bun/bin:/home/logica/.krew/bin

## Tools

	go:	/usr/local/go/bin/go: go version go1.24.1 linux/amd64

	gopls:	/home/logica/go/bin/gopls	(version: v0.18.1 built with go: go1.24.1)
	gotests:	/home/logica/go/bin/gotests	(version: v1.6.0 built with go: go1.24.1)
	gomodifytags:	/home/logica/go/bin/gomodifytags	(version: v1.17.0 built with go: go1.24.1)
	impl:	/home/logica/go/bin/impl	(version: v1.4.0 built with go: go1.24.1)
	goplay:	/home/logica/go/bin/goplay	(version: v1.0.0 built with go: go1.24.1)
	dlv:	/home/logica/go/bin/dlv	(version: v1.24.1 built with go: go1.24.1)
	golangci-lint:	/home/logica/go/bin/golangci-lint	(version: v2.0.0 built with go: go1.24.1)
	golangci-lint:	/home/logica/go/bin/golangci-lint	(version: v2.0.0 built with go: go1.24.1)

## Go env

Workspace Folder (vault-provisioner): /home/logica/prj/personal/vault-provisioner

	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/logica/.cache/go-build'
	GOCACHEPROG=''
	GODEBUG=''
	GOENV='/home/logica/.config/go/env'
	GOEXE=''
	GOEXPERIMENT=''
	GOFIPS140='off'
	GOFLAGS=''
	GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2113586740=/tmp/go-build -gno-record-gcc-switches'
	GOHOSTARCH='amd64'
	GOHOSTOS='linux'
	GOINSECURE=''
	GOMOD='/home/logica/prj/personal/vault-provisioner/go.mod'
	GOMODCACHE='/home/logica/go/pkg/mod'
	GONOPROXY=''
	GONOSUMDB=''
	GOOS='linux'
	GOPATH='/home/logica/go'
	GOPRIVATE=''
	GOPROXY='https://proxy.golang.org,direct'
	GOROOT='/usr/local/go'
	GOSUMDB='sum.golang.org'
	GOTELEMETRY='on'
	GOTELEMETRYDIR='/home/logica/.config/go/telemetry'
	GOTMPDIR=''
	GOTOOLCHAIN='auto'
	GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
	GOVCS=''
	GOVERSION='go1.24.1'
	GOWORK=''
	PKG_CONFIG='pkg-config'

Share the Go related settings you have added/edited

{
  "go.lintTool": "golangci-lint-v2",
}

Describe the bug

ref: #3732

#3732 (comment)

Just tried the fix. I had to add below settings to .golangci.yml in order to generate the path of findings correctly, but other than it it works great! Thanks!

run:                                                                                                   
  relative-path-mode: wd   

#3732 (comment)

  • v1: The report paths were relative to the wd
  • v2: The report paths are relative to the configuration file by default (or wd if no configuration file)

The current extension implementation will only work:

  • on files at the root level (if there is a configuration file)
  • or with relative-path-mode: wd (but the paths inside the configuration will not work)
  • or without a configuration file.

Steps to reproduce the behavior:

#3732 (comment)

To illustrate the problem with relative-path-mode: wd, if we have the following configuration:

  exclusions:
    rules:
      - linters:
          - lll
        path: api/*

And if you edit a file inside api/, you will have reports from lll, but it should not.

Screenshots or recordings

If applicable, add screenshots or recordings to help explain your problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions