为什么无法构建godef.go文件?

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

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

参考:

Command go

英文:

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:

Command go

huangapple
  • 本文由 发表于 2017年5月28日 15:46:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/44224955.html
匿名

发表评论

匿名网友

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

确定