[英]Choose a different executable name in a “go-getable” package
Is it possible to have a cli-package ( package main
) which is "go-getable", but the binary is installed under a different name? 是否可以有一个cli-package( package main
),它可以“获取”,但二进制文件的安装名称不同?
For example to have a repository github.com/exaring/foo-cli 例如,拥有一个存储库github.com/exaring/foo-cli
But go get github.com/foo/foo-cli
would install a binary called foo
(not foo-cli
)? 但是go get github.com/foo/foo-cli
是否会安装一个名为foo
的二进制文件(不是foo-cli
)?
The point is to have an expressive repository name but a short and easy to type executable. 关键是要有一个表达性的存储库名称,但要简短易写。
If you're fine with the user running go build
instead of go get
, you can do this: 如果您对运行go build
而不是go get
的用户感到满意,则可以执行以下操作:
go build -o foo github.com/foo/foo-cli
Otherwise, you can keep all the CLI code in foo-cli
and put the main
function in foo
. 否则,您可以将所有CLI代码保留在foo-cli
,并将main
函数放置在foo
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.