go install

go install

将编译的中间文件放在 GOPATH 的 pkg 目录下,以及固定地将编译结果放在 GOPATH 的 bin 目录下。

go install的编译规律:
  • go install 是建立在 GOPATH 上的,无法在独立的目录里使用 go install。
  • GOPATH 下的 bin 目录放置的是使用 go install 生成的可执行文件,可执行文件的名称来自于编译时的包名。
  • go install 输出目录始终为 GOPATH 下的 bin 目录,无法使用-o附加参数进行自定义。
  • GOPATH 下的 pkg 目录放置的是编译期间的中间文件。
示例:

通过gopm get -g github.com/xxx下载golang包时,往往没有安装。在$GOPATH/bin看到相应的可执行文件。比如cobra、 protoc-gen-go、protoc-gen-gogofaster等。

以下载 && 安转 https://github.com/gogo/protobuf/tree/master/protoc-gen-gogofast为例:

  1. gopm get -g github.com/gogo/protobuf/tree/master/protoc-gen-gogofast
  2. cd $GOPAHT/src/github.com/gogo/protobuf/tree/master/protoc-gen-gogofast
  3. go install

命令执行之后,就可以在$GOPATH/bin下看到可执行文件protoc-gen-gogofast

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值