go install不能识别“-o”旗 [英] go install does not recognize "-o" flag

查看:66
本文介绍了go install不能识别“-o”旗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试执行 go install ,并使用 -o 标志重命名输出。

  go install -o bar.exe src / foo.go 

但是,这个错误会失败:

 定义:-o 
用法:install [构建标志] [包]

go help build 显示 -o 作为正确的构建标志来重命名输出二进制文件。没有提到这个标记没有被定义为 go install



go run -o bar.exe src / foo.go 失败,出现相同的错误。



go build -o bar。 exe src / foo.go 的作品。我得到了bar.exe。



那么这只是文档的错误,或者我错过了什么?

我的版本: go1.5 windows / 386



谢谢。

div class =h2_lin>解决方案

go build 接受 -o 标志,但 go install 不。

go install 将始终输出为 $ GOPATH / bin



如果您想为您的gopath安装自定义二进制名称,您可以执行 go build -o $ GOPATH / bin / whatever ,这大致相当于 go install


I'm trying to do a go install and rename the output with the -o flag.

go install -o bar.exe src/foo.go

But this fails with the error:

flag provided but not defined: -o
usage: install [build flags] [packages]

go help build shows -o as the correct build flag to rename the output binary. There is no mention that this flag is not defined for go install.

go run -o bar.exe src/foo.go fails with the same error.

go build -o bar.exe src/foo.go works. I get bar.exe.

So is this just an error of documentation, or have I missed something?

My version: go1.5 windows/386.

Thanks.

解决方案

go build accepts the -o flag but go install does not.

go install will always output to $GOPATH/bin

If you want to install a custom binary name to your gopath you can do go build -o $GOPATH/bin/whatever and that will be roughly equivalent to go install

这篇关于go install不能识别“-o”旗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆