参考:https://go.dev/blog/using-go-modules
go mod initcreates a new module, initializing thego.modfile that describes it.go build,go test, and other package-building commands add new dependencies togo.modas needed.go list -m allprints the current module’s dependencies.go getchanges the required version of a dependency (or adds a new dependency).go mod tidyremoves unused dependencies.
注意go get的主要作用是修改依赖的module的版本,go get xxxx 时,其实等价于go get xxx@latest,使之本项目需要依赖最新版本的xxx模块,而通过go get xxx @version 来指定版本,不只是下载指定版本的模块,还可以改变go.mod中的依赖项的版本。
最后
以上就是潇洒白开水最近收集整理的关于GO module的正确用法的全部内容,更多相关GO内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复