Go get the difference in the go mod directory command to perform the normal directory

  1. Non- $GOPATHdirectory under the go modproject
$ go mod init test
$ cat go.mod 
module test

go 1.12
$ go get github.com/jinzhu/gorm
$ cat go.mod 
module test

go 1.12

require github.com/jinzhu/gorm v1.9.8 // indirect

Can be seen in go modthe next initialization of the project directory go get package, it will packagebe downloaded to $GOPATH/pkgthe directory install , and add or update a file to go.mod

When you want to modify packagethe time of release, only go get package@指定的version, go.modwill be updated accordingly

  1. Non- go modProject
 $ pwd
/Users/sunnky/go/src/github.com/jinzhu
$ ls
inflection      now
$ go get github.com/jinzhu/gorm
$ ls
gorm            inflection      now

Non- go modproject execution go get package, but will packagebe downloaded to $GOPATH/src/...the directory installation

Reproduced in: https: //www.jianshu.com/p/0a2ebb07da54

Guess you like

Origin blog.csdn.net/weixin_33910385/article/details/91199211