Open gustafj opened 6 years ago
(CC: @alandonovan @griesemer )
go/types doesn't know anything about C; it only knows about the .go
files (or package) it is presented with. Since go/types is not run via the go command, cgo is not run and it doesn't see the cgo generated files (which contain the relevant definitions).
When go/types sees an import "C"
, it "fakes" that import and silently suppresses all errors that would arise from qualified identifiers of the form C.foo
. Thus it "works" ok with C.foo
style identifiers.
There's no easy fix.
Cgo struct types of the form
_Ctype_struct_
seems to be unknown togotype
.What version of Go are you using (
go version
)?go version go1.10.2 linux/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64" GOOS="linux" GCCGO="gccgo" CC="gcc" CXX="g++" CGO_ENABLED="1"
What did you do?
Lint using
gotype
a dummy package which importsgithub.com/google/gopacket/pcap
.$ go get -u github.com/google/gopacket/pcap
$ gotype dummy.go
What did you expect to see?
No output (as in everything is OK).
What did you see instead?
Running
gotype
ongithub.com/google/gopacket/pcap
directly gives: