GO module的正确用法
参考: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中的依赖项的版本。

浙公网安备 33010602011771号