Skip to content

Unintuitive behavior: --print-resources-usage flag only works in combination with --verbose #5859

@null-dev

Description

@null-dev

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?

Docker

Description of the problem

The --print-resources-usage flag only works when used with the --verbose flag:

root@container:/go/src/sample# golangci-lint run --print-resources-usage
0 issues.
root@container:/go/src/sample# golangci-lint run --print-resources-usage -v
INFO golangci-lint has version 2.1.6 built with go1.24.2 from eabc2638 on 2025-05-04T15:41:19Z 
INFO [config_reader] Config search paths: [./ /go/src/sample /go/src /go / /root] 
INFO [config_reader] Module name "sample"         
INFO maxprocs: Leaving GOMAXPROCS=32: CPU quota undefined 
INFO [goenv] Read go env for 2.253914ms: map[string]string{"GOCACHE":"/root/.cache/go-build", "GOROOT":"/usr/local/go"} 
INFO [lintersdb] Active 5 linters: [errcheck govet ineffassign staticcheck unused] 
INFO [loader] Go packages loading at mode 8767 (compiled_files|deps|name|exports_file|files|imports|types_sizes) took 48.552076ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 67.221µs 
INFO [linters_context/goanalysis] analyzers took 0s with no stages 
INFO [runner] processing took 1.9µs with stages: max_same_issues: 410ns, path_absoluter: 220ns, exclusion_paths: 190ns, exclusion_rules: 140ns, max_per_file_from_linter: 120ns, source_code: 110ns, path_relativity: 110ns, max_from_linter: 80ns, nolint_filter: 60ns, diff: 60ns, filename_unadjuster: 50ns, severity-rules: 40ns, invalid_issue: 40ns, uniq_by_line: 40ns, path_shortener: 40ns, cgo: 40ns, generated_file_filter: 40ns, fixer: 40ns, sort_results: 40ns, path_prettifier: 30ns 
INFO [runner] linters took 464.977µs with stages: goanalysis_metalinter: 433.967µs 
0 issues.
INFO File cache stats: 0 entries of total size 0B 
INFO Memory: 2 samples, avg is 45.8MB, max is 45.8MB 
INFO Execution took 51.625923ms

This doesn't appear to be documented anywhere, and no warning is printed either.

In fact, the --print-resources-usage flag is mostly useless now, as just the -v flag by itself is enough to enable resource tracking:

Show output:
root@container:/go/src/sample# golangci-lint run -v
INFO golangci-lint has version 2.1.6 built with go1.24.2 from eabc2638 on 2025-05-04T15:41:19Z 
INFO [config_reader] Config search paths: [./ /go/src/sample /go/src /go / /root] 
INFO [config_reader] Module name "sample"         
INFO maxprocs: Leaving GOMAXPROCS=32: CPU quota undefined 
INFO [goenv] Read go env for 2.311455ms: map[string]string{"GOCACHE":"/root/.cache/go-build", "GOROOT":"/usr/local/go"} 
INFO [lintersdb] Active 5 linters: [errcheck govet ineffassign staticcheck unused] 
INFO [loader] Go packages loading at mode 8767 (files|imports|types_sizes|exports_file|name|compiled_files|deps) took 52.602076ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 70.651µs 
INFO [linters_context/goanalysis] analyzers took 0s with no stages 
INFO [runner] processing took 7.45µs with stages: max_same_issues: 1.56µs, path_absoluter: 1.09µs, path_relativity: 940ns, exclusion_paths: 540ns, exclusion_rules: 540ns, nolint_filter: 400ns, severity-rules: 300ns, max_from_linter: 290ns, path_shortener: 240ns, path_prettifier: 240ns, uniq_by_line: 220ns, sort_results: 210ns, source_code: 180ns, max_per_file_from_linter: 170ns, diff: 140ns, invalid_issue: 130ns, filename_unadjuster: 120ns, fixer: 50ns, generated_file_filter: 50ns, cgo: 40ns 
INFO [runner] linters took 1.347421ms with stages: goanalysis_metalinter: 1.261589ms 
0 issues.
INFO File cache stats: 0 entries of total size 0B 
INFO Memory: 2 samples, avg is 40.2MB, max is 44.6MB 
INFO Execution took 56.934062ms                   
root@container:/go/src/sample#

Related code

The default log level is WARN:

level: LogLevelWarn,

Resource usage tracking is enabled if -v or if --print-resources-usage is passed:

needTrackResources := logutils.IsVerbose() || c.opts.PrintResourcesUsage

Resource usage is printed at the INFO log level:

logger.Infof("Memory: %d samples, avg is %.1fMB, max is %.1fMB",
iterationsCount, avgRSSMB, maxRSSMB)
logger.Infof("Execution took %s", time.Since(startedAt))

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version 2.1.6 built with go1.24.2 from eabc2638 on 2025-05-04T15:41:19Z

Configuration

golangci-lint run --print-resources-usage

Go environment

$ go version && go env
go version go1.24.2 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=''
GOCACHE='/root/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/root/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3345645888=/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='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.24.2'
GOWORK=''
PKG_CONFIG='pkg-config'

Verbose output of running

Not applicable.

A minimal reproducible example or link to a public repository

docker run -it --rm golangci/golangci-lint:v2.1.6 bash
root@container:/go# mkdir src/sample && cd src/sample
root@container:/go/src/sample# go mod init
go: creating new go.mod: module sample
root@container:/go/src/sample# echo 'package main; func main(){ println(42) }' > main.go
root@container:/go/src/sample# go run .
42
root@container:/go/src/sample# golangci-lint run --print-resources-usage
0 issues.
root@container:/go/src/sample#

Validation

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

Supporter

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions