首先,我提取源代码或zipfile,当我构建godef.go时,它们都显示相同的错误日志。

go build godef.go
# command-line-arguments
.\godef.go:55: undefined: acmeFile
.\godef.go:59: undefined: acmeCurrentFile

最佳答案

从多文件Go包或命令构建单个Go文件没有任何意义。生成所有文件。例如,

$ go build godef.go acme.go doc.go

要么
$ go build *.go

或者,只需构建包或命令
$ go build github.com/rogpeppe/godef

为什么要使用go build而不是go install

为什么要“拉出原始的[sic]代码或zipfile”?使用go get,它可以为您执行go install,例如,
$ go get -v -u github.com/rogpeppe/godef
github.com/rogpeppe/godef (download)
github.com/rogpeppe/godef/vendor/9fans.net/go/plan9
github.com/rogpeppe/godef/go/token
github.com/rogpeppe/godef/go/scanner
github.com/rogpeppe/godef/go/ast
github.com/rogpeppe/godef/vendor/9fans.net/go/plan9/client
github.com/rogpeppe/godef/vendor/9fans.net/go/acme
github.com/rogpeppe/godef/go/parser
github.com/rogpeppe/godef/go/printer
github.com/rogpeppe/godef/go/types
github.com/rogpeppe/godef

参考:

Command go

10-08 11:53