Closed
Description
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?
Nix
Description of the problem
Unfortunately the project I ran golangci-lint is not open source but I can share so much:
Inside the project exists a pkg/nxos/10_4_3
a directory with auto generated code with lots of reflections. There are roughly 50 auto files between ~7k and ~12k lines, sometimes 28k each. The type names in there are pretty long and it is often that they exceed 100 characters.
When running golangci-lint on that repo with the dupl linter enabled we hit the following panic:
I know that this is not much to work with but I could run debugging code on the repo to shade some more details on this. From my first naive look it looks like that we are trying to read from closed channels 😅
When removing dupl from our config the issue no longer appears.
Version of golangci-lint
➜ golangci-lint --version
golangci-lint has version 1.64.5 built with go1.24.0 from v1.64.5 on 19700101-00:00:00
Configuration
################################################################################
# This file is AUTOGENERATED with <https://github.com/sapcc/go-makefile-maker> #
# Edit Makefile.maker.yaml instead. #
################################################################################
# Copyright 2024 SAP SE
# SPDX-License-Identifier: Apache-2.0
run:
timeout: 5m # 1m by default
modules-download-mode: readonly
output:
# Do not print lines of code with issue.
print-issued-lines: false
issues:
exclude:
# It is idiomatic Go to reuse the name 'err' with ':=' for subsequent errors.
# Ref: https://go.dev/doc/effective_go#redeclaration
- 'declaration of "err" shadows declaration at'
exclude-dirs:
- pkg/nxos/*
exclude-rules:
- path: _test\.go
linters:
- bodyclose
- dupl
# '0' disables the following options.
max-issues-per-linter: 0
max-same-issues: 0
linters-settings:
dupl:
# Tokens count to trigger issue, 150 by default.
threshold: 100
errcheck:
# Report about assignment of errors to blank identifier.
check-blank: true
# Do not report about not checking of errors in type assertions.
# This is not as dangerous as skipping error values because an unchecked type assertion just immediately panics.
# We disable this because it makes a ton of useless noise esp. in test code.
check-type-assertions: false
forbidigo:
analyze-types: true # required for pkg:
forbid:
# ioutil package has been deprecated: https://github.com/golang/go/issues/42026
- ^ioutil\..*$
# Using http.DefaultServeMux is discouraged because it's a global variable that some packages silently and magically add handlers to (esp. net/http/pprof).
# Applications wishing to use http.ServeMux should obtain local instances through http.NewServeMux() instead of using the global default instance.
- ^http\.DefaultServeMux$
- ^http\.Handle(?:Func)?$
# Forbid usage of old and archived square/go-jose
- pkg: ^gopkg\.in/square/go-jose\.v2$
msg: "gopk.in/square/go-jose is archived and has CVEs. Replace it with gopkg.in/go-jose/go-jose.v2"
- pkg: ^github.com/coreos/go-oidc$
msg: "github.com/coreos/go-oidc depends on gopkg.in/square/go-jose which has CVEs. Replace it with github.com/coreos/go-oidc/v3"
- pkg: ^github.com/howeyc/gopass$
msg: "github.com/howeyc/gopass is archived, use golang.org/x/term instead"
goconst:
ignore-tests: true
min-occurrences: 5
gocritic:
enabled-checks:
- boolExprSimplify
- builtinShadow
- emptyStringTest
- evalOrder
- httpNoBody
- importShadow
- initClause
- methodExprCall
- paramTypeCombine
- preferFilepathJoin
- ptrToRefParam
- redundantSprint
- returnAfterHttpError
- stringConcatSimplify
- timeExprSimplify
- truncateCmp
- typeAssertChain
- typeUnparen
- unnamedResult
- unnecessaryBlock
- unnecessaryDefer
- weakCond
- yodaStyleExpr
goimports:
# Put local imports after 3rd-party packages.
local-prefixes: github.wdf.sap.corp/cc/nxos-gnmi-go
gomoddirectives:
replace-allow-list:
# for go-pmtud
- github.com/mdlayher/arp
toolchain-forbidden: true
gosec:
excludes:
# gosec wants us to set a short ReadHeaderTimeout to avoid Slowloris attacks, but doing so would expose us to Keep-Alive race conditions (see https://iximiuz.com/en/posts/reverse-proxy-http-keep-alive-and-502s/)
- G112
# created file permissions are restricted by umask if necessary
- G306
govet:
enable-all: true
disable:
- fieldalignment
nolintlint:
require-specific: true
stylecheck:
dot-import-whitelist:
- github.com/onsi/ginkgo/v2
- github.com/onsi/gomega
usestdlibvars:
constant-kind: true
crypto-hash: true
default-rpc-path: true
http-method: true
http-status-code: true
sql-isolation-level: true
time-layout: true
time-month: true
time-weekday: true
tls-signature-scheme: true
usetesting:
os-setenv: true
os-temp-dir: true
whitespace:
# Enforce newlines (or comments) after multi-line function signatures.
multi-func: true
linters:
# We use 'disable-all' and enable linters explicitly so that a newer version
# does not introduce new linters unexpectedly.
disable-all: true
enable:
- bodyclose
- containedctx
- copyloopvar
- dupword
- durationcheck
- dupl
- errcheck
- errname
- errorlint
- exptostd
- forbidigo
- ginkgolinter
- gocheckcompilerdirectives
- goconst
- gocritic
- gofmt
- goimports
- gomoddirectives
- gosec
- gosimple
- govet
- ineffassign
- intrange
- misspell
- nilerr
- noctx
- nolintlint
- nosprintfhostport
- perfsprint
- predeclared
- rowserrcheck
- sqlclosecheck
- staticcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- usestdlibvars
- usetesting
- whitespace
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=''
GOCACHE='/home/sandro/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/sandro/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1803264662=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/sandro/src/nxos-gnmi-go/go.mod'
GOMODCACHE='/home/sandro/.cache/go/pkg/mod'
GONOPROXY='git.sr.ht'
GONOSUMDB='git.sr.ht'
GOOS='linux'
GOPATH='/home/sandro/.cache/go'
GOPRIVATE='git.sr.ht'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/nix/store/wk1vg9ksvmqwxhgj7cmvdv1g62v9kff0-go-1.24.0/share/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/sandro/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/nix/store/wk1vg9ksvmqwxhgj7cmvdv1g62v9kff0-go-1.24.0/share/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 1.64.5 built with go1.24.0 from v1.64.5 on 19700101-00:00:00
INFO [config_reader] Config search paths: [./ /home/sandro/src/nxos-gnmi-go /home/sandro/src /home/sandro /home /]
INFO [config_reader] Used config file .golangci.yaml
INFO [goenv] Read go env for 4.392345ms: map[string]string{"GOCACHE":"/home/sandro/.cache/go-build", "GOROOT":"/nix/store/wk1vg9ksvmqwxhgj7cmvdv1g62v9kff0-go-1.24.0/share/go"}
INFO [lintersdb] Active 40 linters: [bodyclose containedctx copyloopvar dupl dupword durationcheck errcheck errname errorlint exptostd forbidigo ginkgolinter gocheckcompilerdirectives goconst gocritic gofmt goimports gomoddirectives gosec gosimple govet ineffassign intrange misspell nilerr noctx nolintlint nosprintfhostport perfsprint predeclared rowserrcheck sqlclosecheck staticcheck stylecheck unconvert unparam unused usestdlibvars usetesting whitespace]
INFO [loader] Go packages loading at mode 8767 (compiled_files|files|name|deps|exports_file|imports|types_sizes) took 402.225914ms
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 1.730194971s
runtime: goroutine stack exceeds 1000000000-byte limit
runtime: sp=0xc2f00ea428 stack=[0xc2f00ea000, 0xc3100ea000]
fatal error: stack overflow
and then the log I already attached above
A minimal reproducible example or link to a public repository
Sorry 😓
// add your code here
Validation
- Yes, I've included all information above (version, config, etc.).
Supporter
- I am a sponsor/backer through GitHub or OpenCollective