It seems that golangci-lint v1.19.0 ignores //lint:ignore comments. Tested with this very simple program:
package main
import (
"fmt"
"time"
)
func main() {
//lint:ignore SA1004 ignore this!
time.Sleep(1)
fmt.Println("hello")
}
golangci-lint v1.19.0 fails with:
main.go:10:13: SA1004: sleeping for 1 nanoseconds is probably a bug. Be explicit if it isn't: time.Sleep(time.Nanosecond) (staticcheck)
time.Sleep(1)
golangci-lint v1.18.0 succeeds as well as staticcheck 2019.2.3.
golangci-lint has version 1.19.0 built from 27ac4c7 on 2019-09-23T20:40:17Zgo version go1.13 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/simon/.cache/go-build"
GOENV="/home/simon/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/simon/workspace/"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/simon/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/simon/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/tmp/foo/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-build335086001=/tmp/go-build -gno-record-gcc-switches"
INFO [config_reader] Config search paths: [./ /tmp/foo /tmp /]
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 1023 (exports_file|files|imports|name|types|types_info|compiled_files|deps|syntax|types_sizes) took 724.109724ms
INFO [runner] worker.8 took 21.127µs with stages: typecheck: 17.201µs
INFO [runner] worker.3 took 94.53µs with stages: varcheck: 81.118µs, structcheck: 8.362µs
INFO [runner] worker.5 took 40.529µs with stages: deadcode: 33.001µs
INFO [runner] worker.7 took 148.077µs with stages: ineffassign: 145.627µs
INFO [runner] worker.2 took 1.143µs
INFO [runner] worker.4 took 129.961µs with stages: errcheck: 111.743µs
INFO [runner] worker.6 took 25.834526ms with stages: govet: 25.829686ms
INFO [runner] worker.1 took 44.510349ms with stages: megacheck: 44.502055ms
INFO [runner] Workers idle times: #2: 44.358168ms, #3: 44.380638ms, #4: 44.284389ms, #5: 44.373782ms, #6: 18.681965ms, #7: 44.369167ms, #8: 44.390642ms
INFO [runner] Processors filtering stat (out/in): filename_unadjuster: 1/1, autogenerated_exclude: 1/1, exclude-rules: 1/1, path_shortener: 1/1, cgo: 1/1, source_code: 1/1, path_prettifier: 1/1, uniq_by_line: 1/1, max_per_file_from_linter: 1/1, max_same_issues: 1/1, skip_dirs: 1/1, identifier_marker: 1/1, exclude: 1/1, nolint: 1/1, diff: 1/1, max_from_linter: 1/1, skip_files: 1/1
INFO [runner] processing took 318.825µs with stages: exclude: 134.356µs, identifier_marker: 57.768µs, autogenerated_exclude: 42.228µs, source_code: 32.72µs, skip_dirs: 17.891µs, nolint: 10.125µs, cgo: 5.393µs, path_prettifier: 4.858µs, uniq_by_line: 3.079µs, filename_unadjuster: 2.773µs, max_same_issues: 2.363µs, max_from_linter: 1.579µs, path_shortener: 1.323µs, skip_files: 740ns, max_per_file_from_linter: 640ns, diff: 619ns, exclude-rules: 370ns
main.go:10:13: SA1004: sleeping for 1 nanoseconds is probably a bug. Be explicit if it isn't: time.Sleep(time.Nanosecond) (staticcheck)
time.Sleep(1)
^
INFO File cache stats: 1 entries of total size 129B
INFO Memory: 9 samples, avg is 121.8MB, max is 136.7MB
INFO Execution took 774.097404ms
Couple notes here, because I just hit this:
// nolint:staticcheck seems to work as a workaround.I also faced this problem. Well, a better workaround would be disabling staticcheck at all and running the updated version from the original source.
I guess we incorrectly configure staticcheck. Contributions are welcome.
Any progress here? Facing the same issue but do not want to disable the checks completely in the project.
Most helpful comment
Couple notes here, because I just hit this:
// nolint:staticcheckseems to work as a workaround.