如果我的Golang软件包名是以下之一,是否可以构建(安装、go get等)名为foobar
的可执行文件:
-
github.com/username/go-foobar
个 -
github.com/username/foobar-tools
个
包根中有main.go
个?
如果我的Golang软件包名是以下之一,是否可以构建(安装、go get等)名为foobar
的可执行文件:
github.com/username/go-foobar
个github.com/username/foobar-tools
个包根中有main.go
个?
go build -o <your desired name>
您可以使用带有go build
的-oswitch 指定可执行文件名称.对于您的示例,它将类似于:
cd $GOPATH/github.com/username/go-foobar && go build -o foobar
.但是,您只剩下软件包文件夹中的可执行文件--您仍然需要以某种方式安装它.
但是,我不知道有什么方法可以指定某人使用go get github.com/username/go-foobar
来安装您的工具.例如,请参阅此答案:https://stackoverflow.com/a/33243591/2415176
如果您不担心用户使用go get
安装您的工具,那么这是一种可以包装在makefile中的东西.