Running golint reveals a lot of failures (mostly exported type comment errors) with the following:
golint -set_exit_status=1 $(go list ./...)
running it with golangci-lint (with enabled golint) does not return the above errors:
golangci-lint -v -e golint run --build-tags integration
I suspect that golint runs not with the above arguments, namely $(go list ./...)...
go version go1.12 linux/amd64
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/mantzas/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/mantzas/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/mantzas/src/beat/rems/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-build031817835=/tmp/go-build -gno-record-gcc-switches"
INFO [config_reader] Config search paths: [./ /home/mantzas/src/beat/rems /home/mantzas/src/beat /home/mantzas/src /home/mantzas /home /]
INFO [lintersdb] Active 10 linters: [deadcode errcheck gosimple govet ineffassign staticcheck structcheck typecheck unused varcheck]
INFO [lintersdb] Optimized sublinters [staticcheck gosimple unused] into metalinter megacheck
INFO [loader] Go packages loading at mode load deps types and syntax took 1.160186581s
INFO [loader] SSA repr building timing: packages building 18.7906ms, total 210.107868ms
INFO [runner] worker.1 took 9.99µs
INFO [runner] worker.11 took 9.02µs
INFO [runner] worker.13 took 5.25µs
INFO [runner] worker.7 took 6.93µs
INFO [runner] worker.5 took 1.44µs
INFO [runner] worker.8 took 2.73µs
INFO [runner] worker.6 took 1.06µs
INFO [runner] worker.9 took 1.95µs
INFO [runner] worker.3 took 5.45µs
INFO [runner] worker.15 took 1.779222ms with stages: errcheck: 1.747192ms, typecheck: 17.43µs
INFO [runner] worker.12 took 2.466463ms with stages: structcheck: 2.463293ms
INFO [runner] worker.2 took 6.275146ms with stages: deadcode: 6.258036ms
INFO [runner] worker.16 took 8.317158ms with stages: varcheck: 8.302598ms
INFO [runner] worker.14 took 18.24481ms with stages: ineffassign: 18.23119ms
INFO [runner] worker.10 took 30.837393ms with stages: govet: 30.818683ms
INFO [runner] worker.4 took 832.582598ms with stages: megacheck: 832.570058ms
INFO [runner] Workers idle times: #1: 832.430548ms, #2: 826.265132ms, #3: 831.885437ms, #5: 832.350908ms, #6: 832.299468ms, #7: 832.387998ms, #8: 832.309528ms, #9: 832.248698ms, #10: 801.741855ms, #11: 832.422038ms, #12: 830.075165ms, #13: 832.395288ms, #14: 814.325658ms, #15: 830.752466ms, #16: 824.23668ms
INFO [runner] Issues before processing: 3, after processing: 0
INFO [runner] processing took 828.071µs with stages: exclude: 376.78µs, skip_dirs: 186.521µs, path_prettifier: 166.45µs, autogenerated_exclude: 69.3µs, cgo: 22.96µs, max_same_issues: 1.29µs, diff: 970ns, nolint: 670ns, skip_files: 670ns, max_from_linter: 570ns, source_code: 570ns, uniq_by_line: 500ns, max_per_file_from_linter: 420ns, path_shortener: 400ns
INFO Memory: 23 samples, avg is 383.7MB, max is 746.6MB
INFO Execution took 2.252028059s
Are you talking about comment on exported type Example should be in the form "Example ..."?
This bugged me too. Try golangci-lint run --exclude-use-default=false ./...
The full list of what's excluded is in the help golangci-lint run -h
@moorepatrick yes. your suggestion did work by enabling golint which is disabled by default. Thanks
This actually does not work anymore...
I confirm it not working (I have the latest golangci-lint), I have the linter enabled (confirmed via golangci-lint linters) and no error is reported from it. If I run it manually, I get plenty of errors.
Adding a verifiable example
https://github.com/alexcpn/golang_grpc_test
Report of Golint here - https://goreportcard.com/report/github.com/alexcpn/golang_grpc_test#golint
:~/coding/golang_grpc_test$ golint server
server/server.go:12:1: comment on exported type Server should be of the form "Server ..." (with optional leading article)
server/server.go:15:1: exported method Server.Search should have comment or be unexported
server/server.go:26:8: if block ends with a return statement, so drop this else and outdent its block
note the last one --> server/server.go:26:8: if block end (actually all since min-confidence is set as 0)
Errors with golangci-lint with golint min-confidence set to 0 .golangci.yml
~/coding/golang_grpc_test$ golangci-lint run --exclude-use-default=false
test_client/client.go:22:18: Error return value of `conn.Close` is not checked (errcheck)
defer conn.Close()
^
integration_test/validation_test.go:56:46: SA1019: grpc.WithDialer is deprecated: use WithContextDialer instead (staticcheck)
conn, err := grpc.DialContext(ctx,"bufnet", grpc.WithDialer(bufDialer),grpc.WithInsecure())
^
integration_test/validation_test.go:80:46: SA1019: grpc.WithDialer is deprecated: use WithContextDialer instead (staticcheck)
conn, err := grpc.DialContext(ctx,"bufnet", grpc.WithDialer(bufDialer),grpc.WithInsecure())
I was experiencing the same issue, but when I updated to v1.18.0 it fixed the problem for me. @mantzas @alexcpn can you see if updating to the latest version fixes it for you?
@steveazz can you provide the command you used?
@mantzas to upgrade? I used curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin v1.18.0 that is specified in the install docs.
The config I used to run my golint is like the following:
linters:
disable-all: true
enable:
- golint
- govet
- gofmt
- gocyclo
issues:
exclude-use-default: false
exclude:
# should have a package comment, unless it's in another file for this package (golint)
- 'in another file for this package'
linters-settings:
gocyclo:
min-complexity: 5
golint:
# minimal confidence for issues, default is 0.8
min-confidence: 0
govet:
# report about shadowed variables
check-shadowing: true
output:
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
format: colored-line-number
# print lines of code with issue, default is true
print-issued-lines: false
# print linter name in the end of issue text, default is true
print-linter-name: true
@steveazz it seems to work again. thanks very much
@jirfag you might want to close this 🙇
Adding a verifiable example
https://github.com/alexcpn/golang_grpc_testReport of Golint here - https://goreportcard.com/report/github.com/alexcpn/golang_grpc_test#golint
:~/coding/golang_grpc_test$ golint server server/server.go:12:1: comment on exported type Server should be of the form "Server ..." (with optional leading article) server/server.go:15:1: exported method Server.Search should have comment or be unexported server/server.go:26:8: if block ends with a return statement, so drop this else and outdent its blocknote the last one --> server/server.go:26:8: if block end (actually all since min-confidence is set as 0)
Errors with golangci-lint with golint min-confidence set to 0 .golangci.yml
~/coding/golang_grpc_test$ golangci-lint run --exclude-use-default=false test_client/client.go:22:18: Error return value of `conn.Close` is not checked (errcheck) defer conn.Close() ^ integration_test/validation_test.go:56:46: SA1019: grpc.WithDialer is deprecated: use WithContextDialer instead (staticcheck) conn, err := grpc.DialContext(ctx,"bufnet", grpc.WithDialer(bufDialer),grpc.WithInsecure()) ^ integration_test/validation_test.go:80:46: SA1019: grpc.WithDialer is deprecated: use WithContextDialer instead (staticcheck) conn, err := grpc.DialContext(ctx,"bufnet", grpc.WithDialer(bufDialer),grpc.WithInsecure())
With v1.180 I am getting (an unwanted) error because of defer usage and some warning from the linter itself
I believe this bug is still open
test_client/client.go:23:18: Error return value of `conn.Close` is not checked (errcheck)
defer conn.Close()
^
WARN [linters context] Panic: buildssa: package "main" (isInitialPkg: true, needAnalyzeSource: true): interface conversion: *ssa.Call is not interface { ssa.setNum(int) }: missing method setNum: goroutine 4563 [running]:
runtime/debug.Stack(0xf45a1e, 0x3c, 0xc0037f9580)
/usr/local/go/src/runtime/debug/stack.go:24 +0x9d
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func1(0xc000119c80)
/home/alex/coding/go/pkg/mod/github.com/golangci/[email protected]/pkg/golinters/goanalysis/runner.go:404 +0x1af
panic(0xda0540, 0xc022a8b110)
/usr/local/go/src/runtime/panic.go:522 +0x1b5
honnef.co/go/tools/ssa.numberRegisters(0xc022c8a000)
/home/alex/coding/go/pkg/mod/honnef.co/go/[email protected]/ssa/func.go:278 +0x114
honnef.co/go/tools/ssa.(*Function).finishBody(0xc022c8a000)
/home/alex/coding/go/pkg/mod/honnef.co/go/[email protected]/ssa/func.go:410 +0x746
honnef.co/go/tools/ssa.(*builder).buildFunction(0xc000bd8a08, 0xc022c8a000)
/home/alex/coding/go/pkg/mod/honnef.co/go/[email protected]/ssa/builder.go:2207 +0x316
honnef.co/go/tools/ssa.(*builder).buildFuncDecl(0xc000bd8a08, 0xc022433500, 0xc0175c0bd0)
/home/alex/coding/go/pkg/mod/honnef.co/go/[email protected]/ssa/builder.go:2225 +0xed
honnef.co/go/tools/ssa.(*Package).build(0xc022433500)
/home/alex/coding/go/pkg/mod/honnef.co/go/[email protected]/ssa/builder.go:2341 +0x88a
sync.(*Once).Do(0xc02243352c, 0xc000bd8c70)
/usr/local/go/src/sync/once.go:44 +0xb3
honnef.co/go/tools/ssa.(*Package).Build(0xc022433500)
/home/alex/coding/go/pkg/mod/honnef.co/go/[email protected]/ssa/builder.go:2260 +0x54
honnef.co/go/tools/internal/passes/buildssa.run(0xc0205b5540, 0x6d81c26a, 0x18a9820, 0x2, 0x2)
/home/alex/coding/go/pkg/mod/honnef.co/go/[email protected]/internal/passes/buildssa/buildssa.go:70 +0x27b
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyze(0xc000119c80)
/home/alex/coding/go/pkg/mod/github.com/golangci/[email protected]/pkg/golinters/goanalysis/runner.go:495 +0x85b
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe(0xc000119c80)
/home/alex/coding/go/pkg/mod/github.com/golangci/[email protected]/pkg/golinters/goanalysis/runner.go:407 +0x51
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func3(0xc0205efa90, 0xc000119c80)
/home/alex/coding/go/pkg/mod/github.com/golangci/[email protected]/pkg/golinters/goanalysis/runner.go:961 +0x5f
created by github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze
/home/alex/coding/go/pkg/mod/github.com/golangci/[email protected]/pkg/golinters/goanalysis/runner.go:956 +0x2cd
ping @steveazz
@alexcpn that seems to be a different error then "Go lints not showing" opening a different issue might be ideal to keep the discussion focus 🙇
For anyone with this problem even in recent releases, keep in mind that the default "issues: exclude{}" config is pretty extensive and may be blocking some very useful warnings. See if adding --exclude-use-default=false reveals your missing issues. IMHO, several of the excludes have gone too far, and generally should be followed when possible.
Most helpful comment
I confirm it not working (I have the latest golangci-lint), I have the linter enabled (confirmed via
golangci-lint linters) and no error is reported from it. If I run it manually, I get plenty of errors.