我是靠谱客的博主 潇洒白开水,这篇文章主要介绍GO module的正确用法,现在分享给大家,希望可以做个参考。

参考:https://go.dev/blog/using-go-modules

  • go mod init creates a new module, initializing the go.mod file that describes it.
  • go buildgo test, and other package-building commands add new dependencies to go.mod as needed.
  • go list -m all prints the current module’s dependencies.
  • go getchanges the required version of a dependency (or adds a new dependency).
  • go mod tidy removes unused dependencies.

注意go get的主要作用是修改依赖的module的版本,go get xxxx 时,其实等价于go get xxx@latest,使之本项目需要依赖最新版本的xxx模块,而通过go get xxx @version 来指定版本,不只是下载指定版本的模块,还可以改变go.mod中的依赖项的版本。

最后

以上就是潇洒白开水最近收集整理的关于GO module的正确用法的全部内容,更多相关GO内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(108)

评论列表共有 0 条评论

立即
投稿
返回
顶部