revive: blank-imports and constant-logical-error do not support cgo
Describe the bug
When using CGO an import "C"
is required to active cgo (and import/define C code). The blank-imports check does not accept this and throws the following warning:
blank-imports: a blank import should be only in a main or test package, or have a comment justifying it (revive)
To Reproduce
Consider this main.go file:
package main
import "unsafe"
// #include <stdlib.h>
import "C"
func main() {
cStr := C.CString("test")
C.free(unsafe.Pointer(cStr))
}
Run revive
for this file and the waring appears for the import "C"
line.
Expected behavior There should not be a warning for this file.
Desktop (please complete the following information):
- OS: Arch Linux
- go version go1.17.7 linux/amd64
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 17
Commits related to this issue
- test case to reproduce issue #635 — committed to mgechev/revive by chavacava 2 years ago
I grabbed and build golangci-lint with this commit and tried. Unfortunately I still have the same issue.
I’ll open an issue at golangci-lint