Skip to content

VS Code integration not working #5617

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

Closed
6 of 7 tasks
jrodriigues opened this issue Mar 25, 2025 · 4 comments
Closed
6 of 7 tasks

VS Code integration not working #5617

jrodriigues opened this issue Mar 25, 2025 · 4 comments
Labels
area: integrations Related to integrations and IDEs question Further information is requested

Comments

@jrodriigues
Copy link

jrodriigues commented Mar 25, 2025

Welcome

  • Yes, I'm using a binary release within 2 latest releases. Only such installations are supported.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've read the typecheck section of the FAQ.
  • Yes, I've tried with the standalone linter if available (e.g., gocritic, go vet, etc.).
  • I agree to follow this project's Code of Conduct

How did you install golangci-lint?

Official binary

Description of the problem

golanci-lint version: 2.0.0
VS Code version version: 1.98.2
VS Code Go extension version: 0.46.1

The VS Code integration suggested here doesn't seem to be working for the linters as I can't see any problems raised, however, when I run golangci-lint run --fast-only from the terminal there are errors being flagged. See details on the verbose output section.

Worth mentioning that the same settings work for the formatter as expected.

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version 2.0.0 built with go1.24.1 from f1f8343d on 2025-03-24T12:12:51Z

Configuration

.golangci.yaml

# https://golangci-lint.run/usage/configuration/

version: "2"

linters:
  default: none
  enable:
    - errcheck # https://github.com/kisielk/errcheck
    - cyclop # https://github.com/bkielbasa/cyclop
    - forcetypeassert # https://github.com/gostaticanalysis/forcetypeassert
    - ineffassign # https://github.com/gordonklaus/ineffassign
    - gocognit # https://github.com/uudashr/gocognit
    - govet # https://pkg.go.dev/golang.org/x/tools/cmd/vet
    - staticcheck # https://staticcheck.devhttps://github.com/dominikh/go-tools/
    - testifylint # https://github.com/Antonboom/testifylint
    - unused # https://github.com/dominikh/go-tools/tree/HEAD/unused

formatters:
  enable:
    - gofumpt # https://github.com/mvdan/gofumpt
  settings:
    gofumpt:
      extra-rules: true
      module-path: my-module-path/custom-dir

vscode settings.json

{
  "[go]": {
    "editor.defaultFormatter": "golang.go"
  },
  "go.useLanguageServer": true,
  "go.lintTool": "golangci-lint",
  "go.lintFlags": ["--fast-only"],
  "go.formatTool": "custom",
  "go.alternateTools": {
    "customFormatter": "golangci-lint"
  },
  "go.formatFlags": ["fmt", "--stdin"],
  "editor.formatOnSave": true
}

Go environment

$ go version && go env
go version go1.24.0 linux/amd64
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='/home/jrodr/.asdf/installs/golang/1.24.0/bin'
GOCACHE='/home/jrodr/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/jrodr/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1356778624=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/jrodr/custom-dir/go.mod'
GOMODCACHE='/home/jrodr/.asdf/installs/golang/1.24.0/packages/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/jrodr/.asdf/installs/golang/1.24.0/packages'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/jrodr/.asdf/installs/golang/1.24.0/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/jrodr/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/jrodr/.asdf/installs/golang/1.24.0/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.24.0'
GOWORK=''
PKG_CONFIG='pkg-config'

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
INFO golangci-lint has version 2.0.0 built with go1.24.1 from f1f8343d on 2025-03-24T12:12:51Z
INFO [config_reader] Config search paths: [./ /home/jrodr/custom-dir /home/jrodr /home /]
INFO [config_reader] Used config file .golangci.yaml
INFO maxprocs: Leaving GOMAXPROCS=20: CPU quota undefined
INFO [goenv] Read go env for 52.673652ms: map[string]string{"GOCACHE":"/home/jrodr/.cache/go-build", "GOROOT":"/home/jrodr/.asdf/installs/golang/1.24.0/go"}
INFO [lintersdb] Active 10 linters: [cyclop errcheck forcetypeassert gocognit gofumpt govet ineffassign staticcheck testifylint unused]
INFO [loader] Go packages loading at mode 8767 (name|compiled_files|exports_file|types_sizes|deps|files|imports) took 223.82576ms
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 389.821µs
INFO [linters_context/goanalysis] analyzers took 15.49214736s with top 10 stages: buildir: 12.494529633s, inspect: 929.649542ms, ctrlflow: 505.467936ms, fact_deprecated: 347.633285ms, printf: 270.023905ms, SA5012: 256.212075ms, fact_purity: 210.328604ms, nilness: 193.50903ms, typedness: 152.262753ms, tokenfileanalyzer: 72.353203ms
INFO [runner/max_same_issues] 2/5 issues with text "error-nil: use assert.NoError" were hidden, use --max-same-issues
INFO [runner] Issues before processing: 16, after processing: 14
INFO [runner] Processors filtering stat (in/out): exclusion_paths: 16/16, exclusion_rules: 16/16, max_same_issues: 16/14, max_from_linter: 14/14, path_prettifier: 14/14, sort_results: 14/14, filename_unadjuster: 16/16, path_relativity: 16/16, nolint_filter: 16/16, fixer: 16/16, max_per_file_from_linter: 16/16, source_code: 14/14, severity-rules: 14/14, cgo: 16/16, uniq_by_line: 16/16, generated_file_filter: 16/16, diff: 16/16, path_shortener: 14/14, path_absoluter: 16/16, invalid_issue: 16/16
INFO [runner] processing took 492.672µs with stages: nolint_filter: 291.767µs, source_code: 95.902µs, generated_file_filter: 43.001µs, max_same_issues: 28.55µs, sort_results: 8.501µs, path_relativity: 8.239µs, uniq_by_line: 4.76µs, max_from_linter: 2.703µs, path_shortener: 1.747µs, cgo: 1.417µs, path_absoluter: 1.123µs, invalid_issue: 962ns, filename_unadjuster: 839ns, max_per_file_from_linter: 758ns, exclusion_rules: 708ns, path_prettifier: 523ns, fixer: 424ns, exclusion_paths: 376ns, diff: 279ns, severity-rules: 93ns
INFO [runner] linters took 5.527625231s with stages: goanalysis_metalinter: 5.527089363s
job/job.go:25:1: calculated cyclomatic complexity for function UnmarshalJSON is 16, max is 10 (cyclop)
func (j *Job) UnmarshalJSON(data []byte) error {
^
cmd/root.go:28:10: Error return value of `cmd.Help` is not checked (errcheck)
        cmd.Help()
                ^
job/job_test.go:107:3: type assertion must be checked (forcetypeassert)
                dbExport := got.Actions[0].(*actions.DbExport)
                ^
job/job_test.go:144:3: type assertion must be checked (forcetypeassert)
                email := got.Actions[0].(*actions.Email)
                ^
database/tests/database_test.go:13:2: error-nil: use assert.NoError (testifylint)
        assert.Nil(t, err)
        ^
database/tests/database_test.go:19:2: error-nil: use assert.NoError (testifylint)
        assert.Nil(t, err)
        ^
job/actions/dbExport_test.go:10:2: useless-assert: asserting of the same variable (testifylint)
        assert.Equal(t, 1, 1)
        ^
job/actions/email_test.go:10:2: useless-assert: asserting of the same variable (testifylint)
        assert.Equal(t, 1, 1)
        ^
job/job_test.go:32:3: error-nil: use assert.NoError (testifylint)
                assert.Nil(err)
                ^
job/job_test.go:47:3: error-nil: use assert.Error (testifylint)
                assert.NotNil(err)
                ^
job/job_test.go:48:3: expected-actual: need to reverse actual and expected values (testifylint)
                assert.Equal(err.Error(), "the job name is not specified or is not a string")
                ^
job/job_test.go:64:3: error-nil: use assert.Error (testifylint)
                assert.NotNil(t, err)
                ^
job/job_test.go:65:3: expected-actual: need to reverse actual and expected values (testifylint)
                assert.Equal(t, err.Error(), "the action type is not specified or is not a string")
                ^
job/job_test.go:80:3: error-nil: use assert.Error (testifylint)
                assert.NotNil(t, err)
                ^
14 issues:
* cyclop: 1
* errcheck: 1
* forcetypeassert: 2
* testifylint: 10
INFO File cache stats: 6 entries of total size 7.3KiB
INFO Memory: 60 samples, avg is 1016.0MB, max is 1732.4MB
INFO Execution took 5.804899692s


$ golangci-lint run --fast-only
job/job.go:25:1: calculated cyclomatic complexity for function UnmarshalJSON is 16, max is 10 (cyclop)
func (j *Job) UnmarshalJSON(data []byte) error {
^
1 issues:
* cyclop: 1

A minimal reproducible example or link to a public repository

N/A

Validation

  • Yes, I've included all information above (version, config, etc.).

Supporter

@jrodriigues jrodriigues added the bug Something isn't working label Mar 25, 2025
Copy link

boring-cyborg bot commented Mar 25, 2025

Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.

@ldez ldez added question Further information is requested and removed bug Something isn't working labels Mar 25, 2025
@ldez
Copy link
Member

ldez commented Mar 25, 2025

Hello,

The configuration suggested by the doc works as expected: the flag --fast-only is not the equivalent of the previous flag --fast.

This is explained here: https://golangci-lint.run/product/migration-guide/#lintersfast

@ldez ldez closed this as completed Mar 25, 2025
@ldez ldez added the area: integrations Related to integrations and IDEs label Mar 25, 2025
@jrodriigues
Copy link
Author

jrodriigues commented Mar 25, 2025

This is explained here: https://golangci-lint.run/product/migration-guide/#lintersfast

I get that, but in my config file I am enabling cyclop which is a fast linter and still getting no problems raised in VS Code.

There was a similar issue raised on vscode-go repo - here.

@ldez
Copy link
Member

ldez commented Mar 25, 2025

#5616 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: integrations Related to integrations and IDEs question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants