errcheck: Fails if anything uses cgo
This is probably a known limitation, but I couldn’t find a ticket for it, so here goes:
errcheck fails if a dependency uses cgo (has import "C"
).
Additionally, it seems impossible to ignore this lack of “C” via -ignorepkg (or I just don’t know how to use the thing).
[0 tv@brute ~/src/2013/errcheck-bug-cgo]$ ls
repro.go
[0 tv@brute ~/src/2013/errcheck-bug-cgo]$ cat repro.go
package main
import _ "github.com/jmhodges/levigo"
func main() {
}
[0 tv@brute ~/src/2013/errcheck-bug-cgo]$ errcheck .
error:failed to check package: could not type check: repro.go:3:10: could not import github.com/jmhodges/levigo (/home/tv/go/src/github.com/jmhodges/levigo/conv.go:4:8: could not import C (cannot find package "C" in any of:
/home/tv/src/go/src/pkg/C (from $GOROOT)
/home/tv/go/src/C (from $GOPATH)))
[1 tv@brute ~/src/2013/errcheck-bug-cgo]$ errcheck -ignorepkg=github.com/jmhodges/levigo .
error:failed to check package: could not type check: repro.go:3:10: could not import github.com/jmhodges/levigo (/home/tv/go/src/github.com/jmhodges/levigo/cache.go:6:8: could not import C (cannot find package "C" in any of:
/home/tv/src/go/src/pkg/C (from $GOROOT)
/home/tv/go/src/C (from $GOPATH)))
[1 tv@brute ~/src/2013/errcheck-bug-cgo]$ errcheck -ignorepkg=C .
error:failed to check package: could not type check: repro.go:3:10: could not import github.com/jmhodges/levigo (/home/tv/go/src/github.com/jmhodges/levigo/iterator.go:6:8: could not import C (cannot find package "C" in any of:
/home/tv/src/go/src/pkg/C (from $GOROOT)
/home/tv/go/src/C (from $GOPATH)))
[1 tv@brute ~/src/2013/errcheck-bug-cgo]$
About this issue
- Original URL
- State: closed
- Created 11 years ago
- Comments: 22 (17 by maintainers)
Commits related to this issue
- Add some preliminary cgo support. Updates #16. — committed to kisielk/errcheck by kisielk 10 years ago
This may be obvious to some, but recording here for future searchers.
I was getting many cgo related errors (when running errcheck inside an alpine linux docker container with no gcc). Fixed them by running:
(edit: set to
0
not1
)