简体   繁体   中英

Strict version on go.mod

My dependencies in go.mod file is always updated and i don't know why. I have go.mod like this

module mymodule

go 1.14

require (
    github.com/golang/protobuf v1.3.5
    github.com/grpc-ecosystem/grpc-gateway v1.14.6
    github.com/jinzhu/gorm v1.9.15
    github.com/kelseyhightower/envconfig v1.4.0
    github.com/ruang-guru/rg-genproto v1.0.18
    gitlab.com/ruangguru/source/shared-lib/go v1.0.28
    google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884
    google.golang.org/grpc v1.29.1
)

when i run go get it always change to this. see github.com/golang/protobuf from 1.3.5 to 1.4.1

require (
    github.com/golang/protobuf v1.4.1
    github.com/gomodule/redigo v2.0.0+incompatible
    github.com/grpc-ecosystem/grpc-gateway v1.14.6
    github.com/jinzhu/gorm v1.9.15
    github.com/kelseyhightower/envconfig v1.4.0
    github.com/ruang-guru/rg-genproto v1.0.18
    github.com/stretchr/testify v1.5.1
    gitlab.com/ruangguru/source/shared-lib/go v1.0.28
    google.golang.org/genproto v0.0.0-20200808173500-a06252235341
    google.golang.org/grpc v1.29.1
    google.golang.org/protobuf v1.25.0 // indirect
)

So my question is how can we set the specific version in go.mod without altering it when we run go get ? I'm sorry if this question is very basic because i am still new to this go.mod thing:(

If your git package has tag version, you can use this command:

go get -d -v github.com/golang/protobuf@v1.3.5
  • -d means "download only", if you want a direct installation, omit this flag and the build commands below this line.
  • -v means "be verbose".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM