Skip to content

cmd/vet: could not import C error when used with -v #21188

Closed
@mvdan

Description

@mvdan

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

go version devel +45a4609c0a Thu Jul 27 05:04:28 2017 +0000 linux/amd64

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

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/mvdan/go/land:/home/mvdan/go"
GORACE=""
GOROOT="/home/mvdan/tip"
GOTOOLDIR="/home/mvdan/tip/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build516844053=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
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"

What did you do?

package main

import "C"

func main() {}
 $ go vet
 $ go vet -v
vet: bug.go:3:8: could not import C (can't find import: "C")
Checking file bug.go
exit status 1

What did you expect to see?

Success, even with -v.

What did you see instead?

The unexpected import error.

go vet -v doesn't have this issue on 1.8.3, so I'm marking as a release blocker for 1.9.

Something to note is that the catalyst for this bug was the fix for #19350 by @robpike. In 1.8, when running go vet -v, the verbose flag wasn't passed to go tool vet, and the bug was hidden away.

But if we run the tool manually in both 1.8.3 and master, it's broken on both:

 $ go tool vet -v .
vet: bug.go:3:8: could not import C (can't find import: "C")
Checking file bug.go
 $ go1 tool vet -v .
vet: bug.go:3:8: could not import C (can't find import: )
Checking file bug.go

The obvious, faster option is to revert 62aeb77. Given that we have a bit of time left until 1.9 is supposed to go out, I'll poke around go tool vet to see if I can fix the bug there.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions