golangci/golangci-lint

Strange behaviour of gofumpt

Closed this issue · 2 comments

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?

go install

Description of the problem

When I run

golangci-lint run --fix I get 0 issues.

But then I run

golangci-lint run I get issues.

Version of golangci-lint

$ golangci-lint --version
# Paste output here
golangci-lint has version 2.2.0 built with go1.24.4 from (unknown, modified: ?, mod sum: "h1:nJBjbPIZEfccWMNCsVkPx++ljjLgsL7KxkORBOJP1zg=") on (unknown)

Configuration

# paste configuration file or CLI flags here
version: "2"

formatters:
  enable:
    - gofmt
    - gofumpt
    - gci
  settings:
    gofmt:
      simplify: true
      rewrite-rules:
        - pattern: 'interface{}'
          replacement: 'any'
    gofumpt:
      extra-rules: true
    gci:
      sections:
        - standard
        - default
        - localmodule

Go environment

$ go version && go env
# paste output here
go version go1.23.7 darwin/arm64
GO111MODULE='on'
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/lv90no/Library/Caches/go-build'
GOENV='/Users/lv90no/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/lv90no/go/pkg/mod'
GONOPROXY='dev.azure.com'
GONOSUMDB='dev.azure.com'
GOOS='darwin'
GOPATH='/Users/lv90no/go'
GOPRIVATE='dev.azure.com'
GOPROXY='https://proxy.golang.org'
GOROOT='/Users/lv90no/go/bin/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.7.darwin-arm64'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/lv90no/go/bin/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.7.darwin-arm64/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.23.7'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/lv90no/Library/Application Support/go/telemetry'
GCCGO='gccgo'
GOARM64='v8.0'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/lv90no/GolandProjects/bug-gofumpt/go.mod'
GOWORK=''
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 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/ck/p_mpjrln3tlb8jbf0g3d2bq40000gp/T/go-build3711877876=/tmp/go-build -gno-record-gcc-switches -fno-common'

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
# paste output here
INFO golangci-lint has version 2.2.0 built with go1.24.4 from (unknown, modified: ?, mod sum: "h1:nJBjbPIZEfccWMNCsVkPx++ljjLgsL7KxkORBOJP1zg=") on (unknown) 
INFO [config_reader] Config search paths: [./ /Users/lv90no/GolandProjects/bug-gofumpt /Users/lv90no/GolandProjects /Users/lv90no /Users /] 
INFO [config_reader] Used config file .golangci.yml 
INFO [config_reader] Module name "bug-gofumpt"    
INFO maxprocs: Leaving GOMAXPROCS=12: CPU quota undefined 
INFO [goenv] Read go env for 5.852625ms: map[string]string{"GOCACHE":"/Users/lv90no/Library/Caches/go-build", "GOROOT":"/Users/lv90no/go/bin/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.7.darwin-arm64"} 
INFO [lintersdb] Active 8 linters: [errcheck gci gofmt gofumpt govet ineffassign staticcheck unused] 
INFO [loader] Go packages loading at mode 8767 (compiled_files|exports_file|files|name|deps|imports|types_sizes) took 961.096167ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 2.141417ms 
INFO [linters_context/goanalysis] analyzers took 1.608142184s with top 10 stages: buildir: 627.657458ms, fact_purity: 173.288544ms, nilness: 141.786716ms, SA5012: 131.462917ms, fact_deprecated: 128.491332ms, typedness: 124.032876ms, ctrlflow: 109.132667ms, printf: 106.831957ms, inspect: 30.045833ms, gofumpt: 5.523251ms 
INFO [runner] Issues before processing: 2, after processing: 1 
INFO [runner] Processors filtering stat (in/out): filename_unadjuster: 2/2, path_relativity: 2/2, generated_file_filter: 2/2, diff: 2/2, max_same_issues: 1/1, max_from_linter: 1/1, path_prettifier: 1/1, invalid_issue: 2/2, exclusion_paths: 2/2, nolint_filter: 2/2, path_shortener: 1/1, severity-rules: 1/1, path_absoluter: 2/2, cgo: 2/2, exclusion_rules: 2/2, fixer: 2/2, uniq_by_line: 2/2, max_per_file_from_linter: 2/1, source_code: 1/1, sort_results: 1/1 
INFO [runner] processing took 81.247µs with stages: nolint_filter: 28.709µs, generated_file_filter: 26.083µs, source_code: 15.083µs, sort_results: 3.416µs, path_relativity: 1.958µs, uniq_by_line: 1.25µs, max_same_issues: 834ns, path_shortener: 749ns, cgo: 458ns, invalid_issue: 417ns, max_per_file_from_linter: 416ns, path_prettifier: 292ns, max_from_linter: 292ns, fixer: 250ns, path_absoluter: 250ns, exclusion_paths: 250ns, filename_unadjuster: 250ns, severity-rules: 125ns, diff: 83ns, exclusion_rules: 82ns 
INFO [runner] linters took 628.806792ms with stages: goanalysis_metalinter: 628.43125ms 
job-runner/cron-job-runner.go:4:1: File is not properly formatted (gofumpt)
        "context"
^
1 issues:
* gofumpt: 1
INFO File cache stats: 1 entries of total size 215B 
INFO Memory: 18 samples, avg is 98.4MB, max is 256.6MB 
INFO Execution took 1.607712375s 

A minimal reproducible example or link to a public repository

// add your code here

I created a small repo with a README: https://github.com/manuelarte/bug-gofumpt

Validation

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

Supporter

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

ldez commented

First-level package/module names are technically reserved for Go itself.
A module name should have a namespace.