I'm running into a weird situation here, hope someone could help me out !
While I was compiling packetbeat source code, I got the following error,
go build
# github.com/elastic/beats/vendor/github.com/tsg/gopacket/pcap
could not determine kind of name for C.PCAP_ERROR_ACTIVATED
could not determine kind of name for C.PCAP_ERROR_IFACE_NOT_UP
could not determine kind of name for C.PCAP_ERROR_NO_SUCH_DEVICE
could not determine kind of name for C.PCAP_ERROR_PERM_DENIED
could not determine kind of name for C.PCAP_WARNING_PROMISC_NOTSUP
could not determine kind of name for C.pcap_activate
could not determine kind of name for C.pcap_can_set_rfmon
could not determine kind of name for C.pcap_create
could not determine kind of name for C.pcap_free_datalinks
could not determine kind of name for C.pcap_offline_filter
could not determine kind of name for C.pcap_set_buffer_size
could not determine kind of name for C.pcap_set_promisc
could not determine kind of name for C.pcap_set_rfmon
could not determine kind of name for C.pcap_set_snaplen
could not determine kind of name for C.pcap_set_timeout
could not determine kind of name for C.pcap_statustostr
clang errors for preamble:
../vendor/github.com/tsg/gopacket/pcap/pcap.go:35:10: error: use of undeclared identifier 'PCAP_ERROR'
return PCAP_ERROR;
^
../vendor/github.com/tsg/gopacket/pcap/pcap.go:47:9: error: use of undeclared identifier 'PCAP_ERROR'
return PCAP_ERROR;
^
2 errors generated.
make: *** [build] Error 2
I checked the pcap.go file and found the two error lines were within the annotation, seems the compiler took the annotation as program statements incorrectly, how did that happen ?
then I tried to build it on Linux, it worked. Below is my environment of GO:
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/yuzhiyu/Documents/programming/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GO15VENDOREXPERIMENT="1"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage- length=0 -fno-common"
CXX="clang++"
CGO_ENABLED="1"
Any idea is appreciated !!