Skip to content

blank-imports and constant-logical-error do not support cgo #635

Closed
@veger

Description

@veger

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions