-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
goimport: check wrong path #824
Comments
@jirfag hi, any update? |
I can't share the code I have that reproduced this, but I'll share what I can. Same linter error, but the reason is different. I have a strong hunch it is the caching layer that was added. I'll explain my reasoning after I dump my info. Version of golangci-lint$ golangci-lint --version
golangci-lint has version v1.21.0 built from (unknown, mod sum: "h1:HxAxpR8Z0M8omihvQdsD3PF0qPjlqYqp2vMJzstoKeI=") on (unknown)
Config file$ cat .golangci.yml
run:
timeout: 5m
tests: false
skip-dirs:
- rpc$
linters-settings:
govet:
check-shadowing: true
depguard:
list-type: whitelist
packages:
- ac.st/
- mesa.ac.st/
- mono.ac.st/
- golang.org/x/
- github.com/joho/godotenv/autoload
- github.com/ianschenck/envflag
- github.com/couchbase/gocb
- github.com/aws/aws-sdk-go
- github.com/aws/aws-lambda-go/lambda
- github.com/golang/protobuf/proto
- github.com/RangelReale/osin
- github.com/google/gofuzz
- github.com/golang/protobuf/ptypes
- gopkg.in/couchbase/gocbcore.v7
- github.com/robfig/cron
- github.com/stathat/go
- github.com/dgrijalva/jwt-go
- github.com/denisenkom/go-mssqldb
- github.com/patrickmn/go-cache
- gopkg.in/gomail.v2
- github.com/pquerna/otp
- github.com/pusher/pusher-http-go
- github.com/sideshow/apns2
- firebase.google.com/go
- google.golang.org/api/option
- github.com/smartystreets/smartystreets-go-sdk/us-street-api
- github.com/smartystreets/smartystreets-go-sdk/wireup
- github.com/smartystreets/smartystreets-go-sdk
- github.com/microcosm-cc/bluemonday
- github.com/aymerick/douceur/inliner
- github.com/jhillyerd/enmime
- github.com/google/go-cmp/cmp
- github.com/google/go-cmp/cmp/cmpopts
- github.com/docker/docker
- github.com/docker/go-connections
- github.com/speps/go-hashids
- github.com/moov-io/ach
- github.com/jackc/pgx
- gopkg.in/jackc/pgx.v2
- github.com/google/go-github
- github.com/lib/pq
- github.com/acst/realm-go-sdk/
- github.com/Pallinder/go-randomdata
- github.com/stretchr/testify
linters:
enable:
- unused
- goconst
- gocyclo
- golint
- ineffassign
- interfacer
- structcheck
- varcheck
- govet
- depguard
- goimports
- misspell
disable-all: true
issues:
exclude-use-default: false Go environment$ go version && go env
go version go1.13.3 darwin/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/willdixon/Library/Caches/go-build"
GOENV="/Users/willdixon/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY="*.ac.st,ac.st,github.com/acst"
GONOSUMDB="*.ac.st,ac.st,github.com/acst"
GOOS="darwin"
GOPATH="/Users/willdixon/.gvm/pkgsets/go1.13.3/global"
GOPRIVATE="*.ac.st,ac.st,github.com/acst"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/willdixon/.gvm/gos/go1.13.3"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/willdixon/.gvm/gos/go1.13.3/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/willdixon/Projects/acst/mono.ac.st/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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/0d/3m7jtb3n6m38r9j2kf9686c00000gn/T/go-build440485480=/tmp/go-build -gno-record-gcc-switches -fno-common"
Verbose output of running$ golangci-lint run -v
INFO [config_reader] Used config file .ci/.golangci.yml
INFO [lintersdb] Active 12 linters: [depguard goconst gocyclo goimports golint govet ineffassign interfacer misspell structcheck unused varcheck]
INFO [loader] Go packages loading at mode 575 (exports_file|files|imports|compiled_files|deps|name|types_sizes) took 1.280307101s
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 18.268349ms
INFO [runner/unused/goanalysis] analyzers took 142.124158ms with top 10 stages: buildssa: 106.625133ms, U1000: 35.499025ms
INFO [runner/goanalysis_metalinter/goanalysis] analyzers took 1.657572912s with top 10 stages: ctrlflow: 318.283588ms, printf: 292.376865ms, inspect: 275.397904ms, goimports: 243.844392ms, golint: 154.780209ms, buildssa: 149.552969ms, ineffassign: 85.899932ms, misspell: 50.46303ms, interfacer: 33.498591ms, varcheck: 11.124487ms
WARN [runner] Can't run linter goanalysis_metalinter: inspect: analysis skipped: errors in package: [/Users/willdixon/Projects/acst/mono.ac.st/pkg/realmsql/pool.go:331:34: cannot use context.Background() (value of type context.Context) as context.Context value in argument to p.shep.GetDatabase: wrong type for method Deadline /Users/willdixon/Projects/acst/mono.ac.st/pkg/realmsql/pool.go:316:36: cannot use context.Background() (value of type context.Context) as context.Context value in argument to p.shep.ListDatabases: wrong type for method Deadline /Users/willdixon/Projects/acst/mono.ac.st/pkg/realmsql/pool.go:280:34: cannot use context.Background() (value of type context.Context) as context.Context value in argument to p.shep.GetDatabase: wrong type for method Deadline /Users/willdixon/Projects/acst/mono.ac.st/pkg/realmsql/pool.go:212:34: cannot use context.Background() (value of type context.Context) as context.Context value in argument to p.shep.GetSiteByID: wrong type for method Deadline]
INFO [runner] processing took 7.123µs with stages: nolint: 2.176µs, max_same_issues: 2.004µs, skip_dirs: 459ns, cgo: 295ns, max_from_linter: 275ns, path_prettifier: 221ns, autogenerated_exclude: 211ns, filename_unadjuster: 207ns, skip_files: 206ns, exclude: 198ns, identifier_marker: 141ns, max_per_file_from_linter: 136ns, uniq_by_line: 136ns, diff: 133ns, path_shortener: 132ns, source_code: 131ns, exclude-rules: 62ns
INFO [runner] linters took 2.884034637s with stages: goanalysis_metalinter: 2.150029736s, unused: 733.935286ms
INFO File cache stats: 40 entries of total size 292.8KiB
INFO Memory: 44 samples, avg is 156.4MB, max is 270.8MB
INFO Execution took 4.213371167s Verbose output of running right after the aboveINFO [config_reader] Used config file .ci/.golangci.yml
INFO [lintersdb] Active 12 linters: [depguard goconst gocyclo goimports golint govet ineffassign interfacer misspell structcheck unused varcheck]
INFO [loader] Go packages loading at mode 575 (files|name|types_sizes|compiled_files|deps|exports_file|imports) took 1.323097512s
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 15.764565ms
INFO [runner/unused/goanalysis] analyzers took 0s with no stages
INFO [runner/goanalysis_metalinter/goanalysis] analyzers took 765.790541ms with top 10 stages: goimports: 221.566039ms, buildssa: 162.992434ms, golint: 127.599893ms, ineffassign: 80.914003ms, misspell: 57.103443ms, interfacer: 39.339366ms, printf: 14.050833ms, ctrlflow: 13.547298ms, varcheck: 8.203296ms, inspect: 5.692812ms
INFO [runner] Issues before processing: 1007, after processing: 2
INFO [runner] Processors filtering stat (out/in): skip_files: 1007/1007, autogenerated_exclude: 4/1007, exclude: 4/4, uniq_by_line: 4/4, cgo: 1007/1007, filename_unadjuster: 1007/1007, nolint: 4/4, path_prettifier: 1007/1007, identifier_marker: 4/4, max_from_linter: 2/2, path_shortener: 2/2, diff: 4/4, max_per_file_from_linter: 2/4, max_same_issues: 2/2, source_code: 2/2, skip_dirs: 1007/1007, exclude-rules: 4/4
INFO [runner] processing took 4.514408ms with stages: autogenerated_exclude: 1.872941ms, path_prettifier: 998.526µs, nolint: 703.673µs, source_code: 323.663µs, skip_dirs: 291.173µs, filename_unadjuster: 115.949µs, cgo: 100.536µs, identifier_marker: 94.799µs, max_same_issues: 3.471µs, uniq_by_line: 2.363µs, max_per_file_from_linter: 2.098µs, max_from_linter: 2.049µs, path_shortener: 1.487µs, exclude: 693ns, diff: 369ns, skip_files: 310ns, exclude-rules: 308ns
INFO [runner] linters took 902.522943ms with stages: goanalysis_metalinter: 574.583916ms, unused: 323.321398ms
services/realm/shepherd/internal/service/service.go:5: File is not `goimports`-ed (goimports)
"github.com/golang/protobuf/ptypes"
services/realm/shepherd/internal/service/service.go:43:1: exported function `HelloWorld` should have comment or be unexported (golint)
func HelloWorld() {
^
INFO File cache stats: 41 entries of total size 299.2KiB
INFO Memory: 24 samples, avg is 80.6MB, max is 136.8MB
INFO Execution took 2.269677646s It seems when I run |
I am tieing it into my CI workflow and I decided to change the version number (keeping go version at 1.13.3 on linux). I can reproduce with 1.20.1 and 1.20.0. Once I went to version 1.19.1 it worked as expected. |
I think it may be the unused linter. Reading through the changes and all the memory improvements being made. removing it from the list of linters for me and I no longer get this warning. |
Confirming I am seeing this issue as well. |
Disabling |
Seems something wrong in |
@jirfag hi, any update? |
@jirfag hi, any update?. |
There’s a bug in golangci-lint where it needs to be run twice. golangci/golangci-lint#824
Can you install another golangci-lint version, run the linter, and check the 1st two warning lines. There might be files that prevent golangci from executing properly. Compiling and building may work fine though. Here's probably a similar case as yours. #827 (comment) |
Is this still relevant? @daixiang0 |
The
expr.y
exists under/go/src/github.com/grafana/loki/pkg/logql
indeed.Reproduce step:
make lint
Version of golangci-lint
Config file
refer to [link](https://github.com/daixiang0/loki/blob/update-golint/.golangci.yml)Go environment
Verbose output of running
The text was updated successfully, but these errors were encountered: