Thank you for creating the issue!
Please include the following information:
Version of golangci-lint
$ sudo docker run --name lint-test --rm -v `pwd`:`pwd` -w `pwd` -it golangci/golangci-lint:v1.28.3 golangci-lint --version
golangci-lint has version 1.28.3 built from 6ab3138 on 2020-07-15T19:07:22Z
I also used the standalone binary of the same version.
$ golangci-lint --version
golangci-lint has version 1.28.3 built from 6ab3138 on 2020-07-11T22:33:41Z
Config file
$ cat .golangci.yml
linters:
enable:
- dogsled
- goimports
- gosec
- stylecheck
- goconst
- depguard
- prealloc
- misspell
- maligned
- dupl
- unconvert
- gofmt
- golint
- gocritic
- scopelint
I get the same results with or without that file being present.
Go environment
$ go version && go env
go version go1.14.5 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/ubuntu/.cache/go-build"
GOENV="/home/ubuntu/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/ubuntu/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/mnt/t/github/placeholder/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build645193424=/tmp/go-build -gno-record-gcc-switches"
Verbose output of running
$ golangci-lint cache clean
$ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /mnt/t/github/placeholder /mnt/t/github /mnt/t /mnt /]
INFO [config_reader] Used config file .golangci.yml
INFO [lintersdb] Active 25 linters: [deadcode depguard dogsled dupl errcheck goconst gocritic gofmt goimports golint gosec gosimple govet ineffassign maligned misspell prealloc scopelint staticcheck structcheck stylecheck typecheck unconvert unused varcheck]
INFO [loader] Go packages loading at mode 575 (exports_file|imports|name|compiled_files|deps|files|types_sizes) took 584.6471ms
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 9.6274ms
INFO [linters context/goanalysis] analyzers took 10.860814s with top 10 stages: buildir: 5.2368889s, goimports: 1.2537639s, fact_deprecated: 684.6718ms, printf: 672.7936ms, ctrlflow: 586.5548ms, fact_purity: 532.3296ms, inspect: 426.6317ms, dupl: 243.2571ms, unconvert: 207.4918ms, misspell: 104.4006ms
INFO [linters context/goanalysis] analyzers took 162.2606ms with top 10 stages: buildir: 139.2902ms, U1000: 22.9704ms
INFO [runner] Issues before processing: 15, after processing: 0
INFO [runner] Processors filtering stat (out/in): path_prettifier: 15/15, filename_unadjuster: 15/15, skip_files: 15/15, identifier_marker: 15/15, exclude: 0/15, skip_dirs: 15/15, autogenerated_exclude: 15/15, cgo: 15/15
INFO [runner] processing took 2.9177ms with stages: autogenerated_exclude: 1.0854ms, path_prettifier: 847.7µs, exclude: 438.4µs, identifier_marker: 348.1µs, skip_dirs: 158.1µs, cgo: 6.2µs, filename_unadjuster: 5.5µs, nolint: 5.1µs, max_same_issues: 2.8µs, max_from_linter: 2.2µs, path_shortener: 2.2µs, skip_files: 2.2µs, diff: 2.1µs, uniq_by_line: 2.1µs, source_code: 2µs, max_per_file_from_linter: 1.9µs, severity-rules: 1.9µs, path_prefixer: 1.9µs, exclude-rules: 1.9µs
INFO [runner] linters took 5.1911579s with stages: goanalysis_metalinter: 4.7229502s, unused: 464.4487ms
INFO File cache stats: 36 entries of total size 226.5KiB
INFO Memory: 60 samples, avg is 235.9MB, max is 339.2MB
INFO Execution took 5.8165646s
The golint tool on the other hand found these issues:
$ golint -set_exit_status $(go list -mod=vendor ./... | grep -v /vendor/)
cmd/pkg1/constants.go:19:7: exported const MB should have comment or be unexported
cmd/pkg2/main.go:38:6: exported type AppConfig should have comment or be unexported
cmd/pkg3/main.go:32:6: exported type Results should have comment or be unexported
events/validate.go:24:1: exported function ValidatePayload should have comment or be unexported
Found 4 lint suggestions; failing.
I tried rolling back as far as v1.21.0 (via Docker container) and didn't have golangci-lint flag the same issues. Those are legitimate warnings/errors btw, I glanced at the source files to make sure that they were not false-positive.
FWIW, I have vendored dependencies and the go.mod file has go 1.13, though I have Go 1.14.5 installed. I get the same results noted above whether I have the vendor folder present or not (temporarily deleted it).
I've used these variations of run:
golangci-lint run -v -E golintgolangci-lint run ./... -v -E golintgolangci-lint run ./... -v --disable-all -E golintall to the same effect: no warnings/errors from golantci-lint, errors/warnings (shown above) from golint.
For completeness, here are the Docker run variations:
sudo docker run --name lint-test --rm -v `pwd`:`pwd` -w `pwd` -it golangci/golangci-lint:v1.28.3 golangci-lint run ./... -v -E golintsudo docker run --name lint-test --rm -v `pwd`:`pwd` -w `pwd` -it golangci/golangci-lint:v1.28.3 golangci-lint run -v -E golintsudo docker run --name lint-test --rm -v `pwd`:`pwd` -w `pwd` -it golangci/golangci-lint:v1.28.3 golangci-lint run -v --disable-all -E golintI even tried the stylecheck linter, but didn't get anything back either.
Just to make sure that the code was even being looked at, I enabled the wsl linter and got back lots of feedback.
Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.
@atc0005 maybe try with running golangci-lint with --exclude-use-default=false flag? I recall it may hide some issues.
@invidian: maybe try with running
golangci-lintwith--exclude-use-default=falseflag? I recall it may hide some issues.
Great suggestion, thank you. After using it I believe I'm getting back the same issues that golint reported earlier. Heh, I'm also getting a number of others I've not previously seen (presumably due to the default exclusions).
Thank you for your help!
Just to be complete (for anyone who comes across this issue in the future), here is the current help text for that flag (spacing tweaked a little to fit better):
--exclude-use-default
Use or not use default excludes:
# EXC0001 errcheck: Almost all programs ignore errors on these functions and in most cases it's ok
- Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked
# EXC0002 golint: Annoying issue about not having a comment. The rare codebase has such comments
- (comment on exported (method|function|type|const)|should have( a package)? comment|comment should be of the form)
# EXC0003 golint: False positive when tests are defined in package 'test'
- func name will be used as test\.Test.* by other packages, and that stutters; consider calling this
# EXC0004 govet: Common false positives
- (possible misuse of unsafe.Pointer|should have signature)
# EXC0005 staticcheck: Developers tend to write in C-style with an explicit 'break' in a 'switch', so it's ok to ignore
- ineffective break statement. Did you mean to break out of the outer loop
# EXC0006 gosec: Too many false-positives on 'unsafe' usage
- Use of unsafe calls should be audited
# EXC0007 gosec: Too many false-positives for parametrized shell calls
- Subprocess launch(ed with variable|ing should be audited)
# EXC0008 gosec: Duplicated errcheck checks
- (G104|G307)
# EXC0009 gosec: Too many issues in popular repos
- (Expect directory permissions to be 0750 or less|Expect file permissions to be 0600 or less)
# EXC0010 gosec: False positive is triggered by 'src, err := ioutil.ReadFile(filename)'
- Potential file inclusion via variable
Since it appears that the behavior is intentional, it's probably worth going ahead and closing this out.
For those more familiar than I, should the docs be updated any further to make note of this behavior, or am I just caught by this perhaps because I'm (still somewhat) new to Go linters?