英文:
why can not build godef.go?
问题
首先,我拉取源代码或压缩文件时,无论是哪种方式,当我执行go build godef.go
时,都会显示相同的错误日志,如下所示:
# command-line-arguments
.\godef.go:55: undefined: acmeFile
.\godef.go:59: undefined: acmeCurrentFile
英文:
>first I pull the soure code or zipfile, They both show the same error log like this when I go build godef.go.
go build godef.go
# command-line-arguments
.\godef.go:55: undefined: acmeFile
.\godef.go:59: undefined: acmeCurrentFile
答案1
得分: 1
从多个Go文件构建单个Go文件包或命令是没有意义的。请构建所有文件。例如,
$ go build godef.go acme.go doc.go
或者
$ go build *.go
或者,简单地构建包或命令
$ go build github.com/rogpeppe/godef
为什么你使用go build
而不是go install
?
为什么你要“拉取源代码或压缩文件”?使用go get
,它会为你执行go install
,例如,
$ go get -v -u github.com/rogpeppe/godef
github.com/rogpeppe/godef (下载)
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
参考:
英文:
Building a single Go file from a multi-file Go package or command makes no sense. Build all the files. For example,
$ go build godef.go acme.go doc.go
or
$ go build *.go
Or, simply build the package or command
$ go build github.com/rogpeppe/godef
Why are you using go build
instead of go install
?
Why did you "pull the soure [sic] code or zipfile"? Use go get
, which does a go install
for you, for example,
$ 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
Reference:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论