Skip to content

Linter does not run on examples/ #5044

Closed
@gucio321

Description

@gucio321

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

Description of the problem

I've noticed that golangci-lint does notrun on files in examples/ folder.
I didn't notice, however, any configuration for that in my .golangci.yam

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version v1.61.0 built with go1.23.1 from (unknown, modified: ?, mod sum: "h1:VvbOLaRVWmyxCnUIMTbf1kDsaJbTzH20FAMXTAlQGu8=") on (unknown)

Configuration

---
linters:
  disable-all: true
  enable:
    - wsl

Go environment

$ go version && go env
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/me/.cache/go-build'
GOENV='/home/me/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/me/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/me/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.23.1'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/me/.config/go/telemetry'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/me/bug/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 -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2812536975=/tmp/go-build -gno-record-gcc-switches'

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
level=info msg="golangci-lint has version v1.61.0 built with go1.23.1 from (unknown, modified: ?, mod sum: \"h1:VvbOLaRVWmyxCnUIMTbf1kDsaJbTzH20FAMXTAlQGu8=\") on (unknown)"
level=info msg="[config_reader] Config search paths: [./ /home/me/bug /home/me /home /]"
level=info msg="[config_reader] Used config file .golangci.yml"
level=info msg="[lintersdb] Active 1 linters: [wsl]"
level=info msg="[loader] Go packages loading at mode 7 (name|compiled_files|files) took 95.785025ms"
level=info msg="[runner/filename_unadjuster] Pre-built 0 adjustments in 97.051µs"
level=info msg="[linters_context/goanalysis] analyzers took 0s with no stages"
level=info msg="[runner/skip_dirs] Skipped 1 issues from dir examples by pattern (^|/)examples($|/)"
level=info msg="[runner] Issues before processing: 2, after processing: 1"
level=info msg="[runner] Processors filtering stat (in/out): cgo: 2/2, identifier_marker: 1/1, uniq_by_line: 1/1, nolint: 1/1, max_from_linter: 1/1, path_shortener: 1/1, filename_unadjuster: 2/2, path_prettifier: 2/2, skip_files: 2/2, skip_dirs: 2/1, exclude: 1/1, path_prefixer: 1/1, fixer: 1/1, sort_results: 1/1, exclude-rules: 1/1, max_per_file_from_linter: 1/1, max_same_issues: 1/1, source_code: 1/1, severity-rules: 1/1, invalid_issue: 2/2, autogenerated_exclude: 1/1, diff: 1/1"
level=info msg="[runner] processing took 125.139µs with stages: exclude-rules: 28.741µs, identifier_marker: 22.003µs, nolint: 17.986µs, path_prettifier: 17.729µs, skip_dirs: 17.364µs, autogenerated_exclude: 8.851µs, source_code: 6.556µs, uniq_by_line: 885ns, max_same_issues: 871ns, invalid_issue: 832ns, cgo: 779ns, path_shortener: 564ns, filename_unadjuster: 505ns, max_from_linter: 439ns, max_per_file_from_linter: 253ns, fixer: 135ns, exclude: 128ns, skip_files: 128ns, diff: 120ns, sort_results: 112ns, path_prefixer: 84ns, severity-rules: 74ns"
level=info msg="[runner] linters took 438.35µs with stages: goanalysis_metalinter: 263.039µs"
pkg/unformatted_file.go:9:2: return statements should not be cuddled if block has more than two lines (wsl)
	return // this should be wsl
	^
level=info msg="File cache stats: 1 entries of total size 112B"
level=info msg="Memory: 2 samples, avg is 27.2MB, max is 27.3MB"
level=info msg="Execution took 99.931469ms"

A minimal reproducible example or link to a public repository

mkdir bug; cd bug
go mod init example.com
mkdir examples

put the above config in .golangci.yaml
put the following code in examples/missformated.go:

package main

import "fmt"

func main() {
   if true {
      fmt.Println("hello-world")
   }
   return // this is a wsl
}

run:

cp -r examples pkg

now when running golangci-lint run ./... only one issue will appear

Validation

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

Supporter

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions