Go 报告对外部包导出的常量为 “undefined”。

huangapple go评论98阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2017年8月2日 10:37:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/45450569.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定