Closed
Description
Welcome
- Yes, I'm using a binary release within 2 latest major 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 (https://golangci-lint.run/usage/faq/#why-do-you-have-typecheck-errors).
- Yes, I've tried with the standalone linter if available (e.g., gocritic, go vet, etc.). (https://golangci-lint.run/usage/linters/)
Description of the problem
My code has unhandled errors but running golangci-lint run
has no output/finding.
However running errcheck
which is enabled per default as sub-linter outputs:
main.go:6:11: os.Remove("test")
When I manually write a function that returns an error and i put it in my code without handling the error it will be catched by golangci-lint run
.
So it seems to ignore methods and only checks for functions, but that's just a wild guess...
Version of golangci-lint
$ golangci-lint --version
golangci-lint has version 1.53.3 built with go1.20.5 from 2dcd82f3 on 2023-06-15T10:50:11Z
Configuration
no custom flag:
$golangci-lint run
$golangci-lint help linters
Enabled by default linters:
errcheck: errcheck is a program for checking for unchecked errors in Go code. These unchecked errors can be critical bugs in some cases [fast: false, auto-fix: false]
gosimple (megacheck): Linter for Go source code that specializes in simplifying code [fast: false, auto-fix: false]
govet (vet, vetshadow): Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string [fast: false, auto-fix: false]
ineffassign: Detects when assignments to existing variables are not used [fast: true, auto-fix: false]
staticcheck (megacheck): It's a set of rules from staticcheck. It's not the same thing as the staticcheck binary. The author of staticcheck doesn't support or approve the use of staticcheck as a library inside golangci-lint. [fast: false, auto-fix: false]
typecheck: Like the front-end of a Go compiler, parses and type-checks Go code [fast: false, auto-fix: false]
unused (megacheck): Checks Go code for unused constants, variables, functions and types [fast: false, auto-fix: false]
Go environment
$ go version && go env
go version go1.19.5 darwin/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/alex/Library/Caches/go-build"
GOENV="/Users/alex/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/alex/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/alex/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.19.5"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/alex/workspace/tests/lint/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/yv/2wbqgdnn1f3btm66bpdbp08m0000gn/T/go-build1442240389=/tmp/go-build -gno-record-gcc-switches -fno-common"
Verbose output of running
$ golangci-lint cache clean
$ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /Users/alex/workspace/tests/lint /Users/alex/workspace/tests /Users/alex/workspace /Users/I540852 /Users /]
INFO [lintersdb] Active 7 linters: [errcheck gosimple govet ineffassign staticcheck typecheck unused]
INFO [loader] Go packages loading at mode 575 (compiled_files|exports_file|imports|name|deps|files|types_sizes) took 150.966102ms
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 169.69µs
INFO [linters_context/goanalysis] analyzers took 1.462973115s with top 10 stages: buildir: 633.76638ms, ctrlflow: 155.681628ms, printf: 136.692872ms, fact_deprecated: 130.541631ms, SA5012: 99.74426ms, fact_purity: 94.649374ms, nilness: 87.96792ms, typedness: 81.677296ms, inspect: 39.021007ms, errcheck: 159.796µs
INFO [runner] Issues before processing: 1, after processing: 0
INFO [runner] Processors filtering stat (out/in): autogenerated_exclude: 1/1, exclude: 1/1, cgo: 1/1, skip_files: 1/1, skip_dirs: 1/1, filename_unadjuster: 1/1, identifier_marker: 1/1, path_prettifier: 1/1, exclude-rules: 0/1
INFO [runner] processing took 333.834µs with stages: path_prettifier: 118.973µs, autogenerated_exclude: 90.332µs, identifier_marker: 89.001µs, skip_dirs: 19.728µs, exclude-rules: 7.688µs, cgo: 1.316µs, nolint: 1.049µs, filename_unadjuster: 707ns, max_same_issues: 692ns, uniq_by_line: 649ns, fixer: 633ns, skip_files: 419ns, max_from_linter: 398ns, source_code: 367ns, exclude: 321ns, severity-rules: 314ns, diff: 300ns, path_shortener: 254ns, sort_results: 242ns, path_prefixer: 231ns, max_per_file_from_linter: 220ns
INFO [runner] linters took 889.617387ms with stages: goanalysis_metalinter: 889.169548ms
INFO File cache stats: 0 entries of total size 0B
INFO Memory: 12 samples, avg is 138.3MB, max is 240.0MB
INFO Execution took 1.051132741s
Code example or link to a public repository
package main
import "os"
func main() {
os.Remove("test")
test()
}
func test() error {
return nil
}
Validation
- Yes, I've included all information above (version, config, etc.).