Closed csmithv closed 1 year ago
Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.
What is the Go code you're linting? Your Make file only does golangci-lint run ./...
so what's interesting is a minimal reproducible example with Go/C code.
A heads up is that typecheck
is not a real linter but a way to detect compilation issues. So one thing that would be nice to try and attach would be the result of go build ./...
. If that does not compile it's not an issue with golangci-lint
.
I am also seeing the same issue when using an alpine image getting the following error. On the latest build of golangci-lint and Go
golangci-lint run
../../../../usr/local/go/src/runtime/cgo/cgo.go:33:8: could not import C (cgo preprocessing failed) (typecheck)
import "C"
^
Okay so my issue here is I needed to install the build-base
package on alpine
by running apk add build-base
@csmithv you may need to resolve some OS level dependency.
Encountered the same issue on Ubuntu, solved by running apt install build-essential
.
Encountered this same issue yesterday. I do have build-essential
and gcc
installed. but the error still exists.
the exact message is as follows. It also prints incorrect errors before the cgo error.
...
...:37:6: undeclared name: `redis` (typecheck)
DB *redis.Client
^
...: "github.com/go-redis/redis/v8" imported but not used (typecheck)
"github.com/go-redis/redis/v8"
../../../../../snap/golangci-lint/104/src/runtime/cgo/cgo.go:34:8: could not import C (cgo preprocessing failed) (typecheck)
import "C"
Apparently the reason was snap. I removed my snap installation of golangci-lint
and installed the binary and it worked
Had the same issue when using it in a Github action and fixed with apt install build-essential
.
What was weird is that the go build ./...
was working even without installing build essential and only golangci-lint run ./...
was failing.
Encountered the same issue on Mac M1 , solved after update brew and reinstall it
brew update
brew install golangci-lint
Still the same issue under alpine linux.
I use lint in docker jenkins/jenkins:lts-alpine.
+ golangci-lint --version
golangci-lint has version v1.50.1 built from (unknown, mod sum: "h1:C829clMcZXEORakZlwpk7M4iDw2XiwxxKaG504SZ9zY=") on (unknown)
+ make lint
# run golangci-lint
golangci-lint run
app/shentong/aci.go:4:8: could not import C (cgo preprocessing failed) (typecheck)
import "C"
^
make: *** [Makefile:78: lint] Error 1
Build step 'Execute shell' marked build as failure
[SSH] executing post build script:
Welcome
Description of the problem
Hello getting the following error on my go project anytime I try to run golanci-lint on it. There was a very similar bug posted on this repo, but I think that this might be getting caused by a different issue. For background, this was correctly running yesterday, I did not change anything in the code, and my make command started failing with this issue. I know that's difficult to believe, but I even reverted to the last github push that I was confident ran "make" correctly and it started failing.
Some common errors I have checked: gcc is installed with version 9.4.0
Version of golangci-lint
Configuration file
Go environment
Verbose output of running
Code example or link to a public repository