gpt4 book ai didi

go - go get 和 go install 有什么区别?

转载 作者:IT老高 更新时间:2023-10-28 12:58:34 26 4
gpt4 key购买 nike

go工具玩了一会,貌似go get:

  1. (可选)下载,
  2. 编译,
  3. 并安装

一个软件,而去安装简单

  1. 编译
  2. 并安装

它。在这种情况下,为什么 go install 命令存在,因为 go get 取代了它?

最佳答案

go install 是本地工作时工作流程的一部分。假设您想使用一个库,但由于某种原因需要进行更改。你会这样做:

  • go get -d library,只下载它;
  • 对下载的包进行更改;
  • go install library 安装本地版本。

据我所知 go get 没有标志表明它应该 下载,所以它不能在这里替换 go install .

从头开始开发新包时使用相同的工作流程。

编辑:六年后,Go 1.16 更新并阐明了 go installgo get 的用法:https://tip.golang.org/doc/go1.16#modules

go install, with or without a version suffix (as described above), is now the recommended way to build and install packages in module mode. go get should be used with the -d flag to adjust the current module's dependencies without building packages, and use of go get to build and install packages is deprecated. In a future release, the -d flag will always be enabled.

关于go - go get 和 go install 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24878737/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com