nolintlint: removes nolint from docstring, separating docstring from its target

Author: mitarCreated Mar 27, 2026Updated May 1, 2026
Labelsbugarea: nolint

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

When nolintlint removes unnecessary //nolint comment from a docstring, that docstring becomes separated from its target.

Version of golangci-lint

bash
$ golangci-lint --version
golangci-lint has version 2.11.4 built with go1.26.1 from 8f3b0c7e on 2026-03-22T17:35:14Z

Configuration

bash
golangci-lint run --enable nolintlint --enable lll --fix test.go

Go environment

bash
$ go version && go env
go version go1.26.1 linux/amd64
AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='0'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/root/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/root/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build4175435942=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/dev/null'
GOMODCACHE='/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/root/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.26.1'
GOWORK=''
PKG_CONFIG='pkg-config'

Verbose output of running

bash
$ golangci-lint cache clean
$ golangci-lint run --enable nolintlint --enable lll --fix test.go -v
INFO golangci-lint has version 2.11.4 built with go1.26.1 from 8f3b0c7e on 2026-03-22T17:35:14Z 
INFO [config_reader] Config search paths: [./ /tmp / /root] 
INFO [goenv] Read go env for 2.543754ms: map[string]string{"GOCACHE":"/root/.cache/go-build", "GOROOT":"/usr/local/go"} 
INFO [lintersdb] Active 7 linters: [errcheck govet ineffassign lll nolintlint staticcheck unused] 
INFO [loader] Go packages loading at mode 8767 (deps|files|imports|compiled_files|exports_file|name|types_sizes) took 42.282407ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 220.422µs 
INFO [linters_context/goanalysis] analyzers took 7.177003ms with top 10 stages: buildir: 711.717µs, nolintlint: 664.725µs, inspect: 664.373µs, fact_deprecated: 537.895µs, errcheck: 436.904µs, printf: 276.505µs, ctrlflow: 265.795µs, unused: 263.993µs, fact_purity: 171.508µs, SA5012: 166.244µs 
INFO [runner] Applying suggested fixes            
INFO [runner] fixer took 155.617µs with stages: all: 155.617µs 
INFO [runner] Issues before processing: 1, after processing: 0 
INFO [runner] Processors filtering stat (in/out): invalid_issue: 1/1, path_relativity: 1/1, exclusion_rules: 1/1, cgo: 1/1, generated_file_filter: 1/1, diff: 1/1, exclusion_paths: 1/1, nolint_filter: 1/1, fixer: 1/0, path_absoluter: 1/1, filename_unadjuster: 1/1 
INFO [runner] processing took 281.745µs with stages: fixer: 178.239µs, nolint_filter: 53.402µs, generated_file_filter: 36.753µs, uniq_by_line: 6.083µs, sort_results: 1.124µs, path_relativity: 1.079µs, max_same_issues: 652ns, invalid_issue: 583ns, exclusion_paths: 581ns, cgo: 463ns, max_per_file_from_linter: 451ns, filename_unadjuster: 441ns, diff: 388ns, exclusion_rules: 341ns, max_from_linter: 285ns, path_absoluter: 256ns, path_prettifier: 246ns, path_shortener: 142ns, source_code: 132ns, severity-rules: 104ns 
INFO [runner] linters took 7.269685ms with stages: goanalysis_metalinter: 6.909687ms 
0 issues.
INFO File cache stats: 1 entries of total size 81B 
INFO Memory: 2 samples, avg is 41.2MB, max is 43.2MB 
INFO Execution took 52.832396ms                   

A minimal reproducible example or link to a public repository

If I have Go file test.go:

go
package test

// MyTest is a great struct.
//
//nolint:lll
type MyTest struct {}

And I run golangci-lint run --enable nolintlint --enable lll --fix test.go, I get the following:

go
package test

// MyTest is a great struct.
//

type MyTest struct{}

Because of an empty line, now this comment is not a docstring comment. So for example, then another linter like revive starts complaining that a docstring is missing for public struct. I think linter should in this case convert to:

go
package test

// MyTest is a great struct.
type MyTest struct{}

Or at least to:

go
package test

// MyTest is a great struct.
//
type MyTest struct{}

Validation

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

Supporter