golangci-lint version 1.42.0 says typecheck
error on Ubuntu 21.04 & Go 1.17 env
#2215
-
Welcome
Description of the problemgolangci-lint version 1.42.0 says Version of golangci-lint$ golangci-lint --version
golangci-lint has version 1.42.0 built from c6142e38 on 2021-08-17T11:47:22Z Configuration file$ cat .golangci.yml
Config file not used Go environment$ go version && go env
go version go1.17 linux/amd64
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/yupeng/.cache/go-build"
GOENV="/home/yupeng/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/yupeng/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/yupeng/go"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/yupeng/Downloads/project-master/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=/tmp/go-build2764735852=/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: [./ /home/yupeng/Downloads/project-master /home/yupeng/Downloads /home/yupeng /home /]
INFO [lintersdb] Active 10 linters: [deadcode errcheck gosimple govet ineffassign staticcheck structcheck typecheck unused varcheck]
INFO [loader] Go packages loading at mode 575 (deps|files|name|types_sizes|compiled_files|exports_file|imports) took 194.674048ms
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 927.492µs
INFO [linters context/goanalysis] analyzers took 7.687601252s with top 10 stages: buildir: 5.676072864s, inspect: 652.652782ms, printf: 269.838943ms, ctrlflow: 269.264356ms, fact_purity: 222.749299ms, nilness: 190.489302ms, fact_deprecated: 177.636696ms, typedness: 107.184266ms, SA5012: 105.989904ms, deadcode: 5.130813ms
INFO [runner/max_same_issues] 2/5 issues with text "undeclared name: `kafka`" were hidden, use --max-same-issues
INFO [runner] Issues before processing: 2079, after processing: 12
INFO [runner] Processors filtering stat (out/in): filename_unadjuster: 2079/2079, exclude: 2079/2079, nolint: 2079/2079, max_per_file_from_linter: 14/14, sort_results: 12/12, exclude-rules: 2079/2079, uniq_by_line: 14/2079, max_same_issues: 12/14, source_code: 12/12, path_shortener: 12/12, severity-rules: 12/12, path_prefixer: 12/12, cgo: 2079/2079, path_prettifier: 2079/2079, skip_files: 2079/2079, identifier_marker: 2079/2079, diff: 14/14, skip_dirs: 2079/2079, autogenerated_exclude: 2079/2079, max_from_linter: 12/12
INFO [runner] processing took 46.47657ms with stages: exclude-rules: 25.694622ms, identifier_marker: 18.418372ms, nolint: 888.248µs, path_prettifier: 842.989µs, skip_dirs: 209.36µs, uniq_by_line: 85.3µs, cgo: 82.249µs, filename_unadjuster: 68.5µs, autogenerated_exclude: 64.33µs, max_same_issues: 55.56µs, source_code: 54.89µs, path_shortener: 3.64µs, max_per_file_from_linter: 3.4µs, max_from_linter: 3.28µs, diff: 600ns, exclude: 350ns, skip_files: 320ns, sort_results: 270ns, severity-rules: 190ns, path_prefixer: 100ns
INFO [runner] linters took 3.973162839s with stages: goanalysis_metalinter: 3.926555699s
logging/logging.go:43:12: undeclared name: `sentry` (typecheck)
if err := sentry.Init(sentry.ClientOptions{
^
logging/logging.go:106:3: undeclared name: `sentry` (typecheck)
sentry.CaptureException(err) // Отправка в sentry
^
logging/logging.go:14:2: "github.com/getsentry/sentry-go" imported but not used (typecheck)
"github.com/getsentry/sentry-go"
^
Producer/Producer.go:12:13: undeclared name: `kafka` (typecheck)
var writer *kafka.Writer
^
Producer/Producer.go:17:10: undeclared name: `kafka` (typecheck)
wr := &kafka.Writer{
^
Producer/Producer.go:18:14: undeclared name: `kafka` (typecheck)
Addr: kafka.TCP(config.AppConfiguration["Kafka"].(map[string]interface{})["Url"].(string)),
^
Producer/Producer.go:5:2: "github.com/segmentio/kafka-go" imported but not used (typecheck)
"github.com/segmentio/kafka-go"
^
applicationstate/redis.go:15:18: undeclared name: `redis` (typecheck)
var redisClient *redis.Client //Клиент редиса
^
applicationstate/redis.go:18:24: undeclared name: `redis` (typecheck)
func NewRedisClient() *redis.Client {
^
applicationstate/redis.go:19:9: undeclared name: `redis` (typecheck)
return redis.NewClient(&redis.Options{
^
applicationstate/redis.go:12:2: "github.com/go-redis/redis/v8" imported but not used (typecheck)
"github.com/go-redis/redis/v8"
^
../../../../usr/local/go/src/runtime/cgo/cgo.go:34:8: could not import C (cgo preprocessing failed) (typecheck)
import "C"
^
INFO File cache stats: 4 entries of total size 8.1KiB
INFO Memory: 43 samples, avg is 242.7MB, max is 341.5MB
INFO Execution took 4.175849029s Code example or link to a public repositoryDemo: https://github.com/khadmitriy/project |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 11 replies
-
Hello,
|
Beta Was this translation helpful? Give feedback.
-
I also meet this problem. Under Go 1.17, |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot @choleraehyq ! Compile from source solved the problem. Me too suspect the precompiled binary is not compiled by Go 1.17 and having compatibility issue on Linux. @ldez Any chance to release a new version to fix this? |
Beta Was this translation helpful? Give feedback.
-
I have the same problem, is it because generics are not supported? Is there a way to filter out the checks on generics while preserving other functionality?
|
Beta Was this translation helpful? Give feedback.
-
please export CGO_ENABLED=0 |
Beta Was this translation helpful? Give feedback.
-
Thank you guys, this discussion is still useful today for Ubuntu Containers, Wed Aug 10 2022... I compiled the version locally, then all works as expected and no typecheck error is shown finally: git clone https://github.com/golangci/golangci-lint.git
cd golangci-lint
make build
chmod +x golangci-lint
mv golangci-lint /usr/bin/golangci-lint
GO111MODULE=on /usr/bin/golangci-lint cache clean
GO111MODULE=on /usr/bin/golangci-lint run --timeout=5m --config ./.golangci.yml |
Beta Was this translation helpful? Give feedback.
-
Hi, I have this issue when running as a github action, have tried to use the supplied |
Beta Was this translation helpful? Give feedback.
I also meet this problem. Under Go 1.17,
go build
success, but golangci-lint installed bycurl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.42.0
saystypecheck
error. Then I build and install golangci-lint locally under Go1.17 usinggo get github.com/golangci/golangci-lint/cmd/[email protected]
, it doesn't saytypecheck
error again.