Skip to content

cmd/vet: go vet failing in directory with cgo and no tests #24193

@variadico

Description

@variadico

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.10 darwin/amd64 on macOS 10.13.3.

Does this issue reproduce with the latest release?

This issue does not happen with 1.9.4, only 1.10.

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/jaime/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/jaime/go"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.10/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.10/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
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=/var/folders/x8/d_hkkg0977n90n6ml16tnqlr0000gn/T/go-build981458154=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I created a package that uses cgo. In that package, I call a function defined in a .h file. Then, I ran go vet on that package.

// bar.go
package bar

/*
#import "bar.h"
*/
import "C"

func Bar() {
	C.bar()
}
// bar.h
int bar() {
	return 42;
}

I've created an isolated example at this repo: https://github.com/variadico/vetbug

What did you expect to see?

go vet should have analyzed the Go source files and reported no errors.

What did you see instead?

go vet failed to run, saying there are no Go source files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions