英文:
Go reports "undefined" for external package exported constant
问题
以下是代码的翻译:
package main
import (
"log"
"github.com/google/gopacket"
"github.com/google/gopacket/pcap"
)
func main() {
log.Print(gopacket.MaxEndpointSize)
log.Print(pcap.MaxBpfInstructions)
}
当我运行 go build
时,我得到了以下错误:
./main.go:11: undefined: pcap.MaxBpfInstructions
但是你可以在这里看到 MaxBpfInstructions
:https://godoc.org/github.com/google/gopacket/pcap#pkg-constants
我觉得这一定是一个愚蠢的错误,但是我找不到它。帮帮我?
英文:
Here's the code:
package main
import (
"log"
"github.com/google/gopacket"
"github.com/google/gopacket/pcap"
)
func main() {
log.Print(gopacket.MaxEndpointSize)
log.Print(pcap.MaxBpfInstructions)
}
When I run go build
I get this:
./main.go:11: undefined: pcap.MaxBpfInstructions
But you can see MaxBpfInstructions
right here: https://godoc.org/github.com/google/gopacket/pcap#pkg-constants
I feel this must be a stupid mistake, but I can't find it. Help?
答案1
得分: 0
看起来我缺少了libpcap-dev
。现在为什么Go或者这个包没有抛出一个正确的错误信息,我不知道。
英文:
It seems I was missing libpcap-dev
. Now why Go or the package didn't throw a proper error message is beyond me.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论