Differences and Ties Between go get and go mod download Commands

There’s a subtle distinction between the go mod download and go get commands when it comes to fetching modules.

go get not only downloads but also adds dependencies straight into your go.mod file.

On the flip side, go mod download insists that the modules you’re after are already declared in go.mod—otherwise, it’ll throw a “cannot resolve” error your way.

go get命令和go mod download命令的区别和联系

go mod download命令和go get命令在下载模块时有一点区别,go get命令下载并添加依赖项到go.mod文件,而go mod download命令要下载的模块必须已经写在go.mod文件里,否则它报一个“无法解析”错误。