-
-
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
Incorrect typecheck "imported but not used" finding #3921
Labels
question
Further information is requested
Comments
Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors. |
ldez
added
question
Further information is requested
and removed
bug
Something isn't working
labels
Jun 20, 2023
Hello, You are using go1.19 locally and in your CI but the project sets go1.20 in its go.mod. go1.20$ docker run --rm -it golang:1.20-alpine sh
/go # apk add git curl
fetch https://dl-cdn.alpinelinux.org/alpine/v3.17/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.17/community/x86_64/APKINDEX.tar.gz
(1/7) Installing brotli-libs (1.0.9-r9)
(2/7) Installing nghttp2-libs (1.51.0-r0)
(3/7) Installing libcurl (8.1.2-r0)
(4/7) Installing curl (8.1.2-r0)
(5/7) Installing libexpat (2.5.0-r0)
(6/7) Installing pcre2 (10.42-r0)
(7/7) Installing git (2.38.5-r0)
Executing busybox-1.35.0-r29.trigger
OK: 16 MiB in 23 packages
/go # curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.53.3
golangci/golangci-lint info checking GitHub for tag 'v1.53.3'
golangci/golangci-lint info found version: 1.53.3 for v1.53.3/linux/amd64
golangci/golangci-lint info installed /go/bin/golangci-lint
/go # git clone --quiet https://github.com/google/go-attestation
/go # cd go-attestation/
/go/go-attestation # golangci-lint run -v
INFO [config_reader] Config search paths: [./ /go/go-attestation /go / /root]
INFO [config_reader] Used config file .golangci.yaml
INFO [lintersdb] Active 7 linters: [gofmt gosimple govet ineffassign staticcheck typecheck unused]
INFO [loader] Go packages loading at mode 575 (exports_file|imports|types_sizes|compiled_files|deps|files|name) took 3.400675401s
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 6.68849ms
INFO [linters_context/goanalysis] analyzers took 3.129663811s with top 10 stages: buildir: 2.084247687s, inspect: 106.394397ms, printf: 58.111377ms, ctrlflow: 56.16251ms, gofmt: 51.700404ms, fact_deprecated: 49.937577ms, fact_purity: 47.73155ms, SA5012: 43.385057ms, S1038: 42.139872ms, nilness: 39.672569ms
INFO [runner] Issues before processing: 1, after processing: 0
INFO [runner] Processors filtering stat (out/in): autogenerated_exclude: 1/1, exclude: 1/1, exclude-rules: 0/1, identifier_marker: 1/1, skip_files: 1/1, cgo: 1/1, filename_unadjuster: 1/1, path_prettifier: 1/1, skip_dirs: 1/1
INFO [runner] processing took 96.535µs with stages: autogenerated_exclude: 28.105µs, identifier_marker: 24.048µs, exclude-rules: 13.604µs, skip_dirs: 13.56µs, path_prettifier: 12.16µs, cgo: 976ns, nolint: 565ns, max_same_issues: 492ns, diff: 474ns, filename_unadjuster: 422ns, skip_files: 328ns, fixer: 307ns, source_code: 281ns, uniq_by_line: 263ns, exclude: 191ns, severity-rules: 190ns, path_shortener: 170ns, max_from_linter: 137ns, sort_results: 109ns, max_per_file_from_linter: 82ns, path_prefixer: 71ns
INFO [runner] linters took 990.624893ms with stages: goanalysis_metalinter: 990.483942ms
INFO File cache stats: 0 entries of total size 0B
INFO Memory: 46 samples, avg is 76.8MB, max is 269.5MB
INFO Execution took 4.401110727s
/go/go-attestation # go build ./...
/go/go-attestation # go1.19$ docker run --rm -it golang:1.19-alpine sh
/go # apk add git curl
fetch https://dl-cdn.alpinelinux.org/alpine/v3.16/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.16/community/x86_64/APKINDEX.tar.gz
(1/7) Installing brotli-libs (1.0.9-r6)
(2/7) Installing nghttp2-libs (1.47.0-r0)
(3/7) Installing libcurl (8.1.2-r0)
(4/7) Installing curl (8.1.2-r0)
(5/7) Installing expat (2.5.0-r0)
(6/7) Installing pcre2 (10.40-r0)
(7/7) Installing git (2.36.6-r0)
Executing busybox-1.35.0-r17.trigger
OK: 20 MiB in 22 packages
/go # curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.53.3
golangci/golangci-lint info checking GitHub for tag 'v1.53.3'
golangci/golangci-lint info found version: 1.53.3 for v1.53.3/linux/amd64
golangci/golangci-lint info installed /go/bin/golangci-lint
/go # git clone --quiet https://github.com/google/go-attestation
/go # cd go-attestation/
/go/go-attestation # golangci-lint run -v
INFO [config_reader] Config search paths: [./ /go/go-attestation /go / /root]
INFO [config_reader] Used config file .golangci.yaml
INFO [lintersdb] Active 7 linters: [gofmt gosimple govet ineffassign staticcheck typecheck unused]
INFO [loader] Go packages loading at mode 575 (types_sizes|compiled_files|files|name|deps|exports_file|imports) took 1.801918445s
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 7.154419ms
INFO [linters_context/goanalysis] analyzers took 1.980360834s with top 10 stages: buildir: 1.427504661s, inspect: 86.960384ms, ctrlflow: 51.102549ms, fact_purity: 47.180505ms, printf: 46.705053ms, fact_deprecated: 44.659417ms, SA5012: 42.670369ms, nilness: 36.978ms, typedness: 34.93439ms, gofmt: 4.282696ms
INFO [runner] Issues before processing: 291, after processing: 3
INFO [runner] Processors filtering stat (out/in): uniq_by_line: 3/291, max_per_file_from_linter: 3/3, severity-rules: 3/3, filename_unadjuster: 291/291, path_prettifier: 291/291, autogenerated_exclude: 291/291, path_prefixer: 3/3, skip_dirs: 291/291, source_code: 3/3, path_shortener: 3/3, max_same_issues: 3/3, max_from_linter: 3/3, fixer: 3/3, identifier_marker: 291/291, nolint: 291/291, diff: 3/3, exclude-rules: 291/291, sort_results: 3/3, cgo: 291/291, skip_files: 291/291, exclude: 291/291
INFO [runner] processing took 5.267985ms with stages: identifier_marker: 2.299534ms, exclude-rules: 2.282836ms, nolint: 496.967µs, path_prettifier: 93.415µs, skip_dirs: 34.231µs, source_code: 29.079µs, cgo: 7.812µs, uniq_by_line: 7.523µs, filename_unadjuster: 5.816µs, autogenerated_exclude: 5.78µs, max_same_issues: 1.888µs, path_shortener: 827ns, max_from_linter: 547ns, max_per_file_from_linter: 469ns, skip_files: 272ns, exclude: 266ns, fixer: 193ns, severity-rules: 177ns, diff: 177ns, sort_results: 100ns, path_prefixer: 76ns
INFO [runner] linters took 824.960401ms with stages: goanalysis_metalinter: 819.641047ms
attest/attest-tool/attest-tool.go:6:2: "crypto/ecdsa" imported and not used (typecheck)
"crypto/ecdsa"
^
attest/challenge_test.go:6:2: "crypto/rsa" imported and not used (typecheck)
"crypto/rsa"
^
../../usr/local/go/src/runtime/cgo/cgo.go:31:8: could not import C (cgo preprocessing failed) (typecheck)
import "C"
^
INFO File cache stats: 3 entries of total size 11.9KiB
INFO Memory: 28 samples, avg is 90.2MB, max is 265.5MB
INFO Execution took 2.636876381s
/go/go-attestation #
/go/go-attestation # go build ./...
../pkg/mod/github.com/google/go-tpm@v0.3.4-0.20230613064043-511507721cb1/legacy/tpm2/credactivation/credential_activation.go:23:2: package crypto/ecdh is not in GOROOT (/usr/local/go/src/crypto/ecdh)
FYI, To see your problem you can run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Welcome
Description of the problem
The
typecheck
linter reports an unused import in the google/go-attestation package, but the import is definitely used in the file that has the report:There are build tags used elsewhere in this module, but not in this file (referencing issue #3891). Running
go mod tidy
doesn't help (referencing issue #2133).I see this in the Github action (example) and when running locally.
Any suggestions?
Version of golangci-lint
Configuration file
Go environment
Verbose output of running
Code example or link to a public repository
https://github.com/google/go-attestation
The text was updated successfully, but these errors were encountered: