简体   繁体   English

go.mod 上的严格版本

[英]Strict version on go.mod

My dependencies in go.mod file is always updated and i don't know why.我在 go.mod 文件中的依赖项总是更新,我不知道为什么。 I have go.mod like this我有这样的 go.mod

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.当我运行go get时,它总是更改为这个。 see github.com/golang/protobuf from 1.3.5 to 1.4.1参见github.com/golang/protobuf从 1.3.5 到 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 ?所以我的问题是我们如何在 go.mod 中设置特定版本而不在运行go get时更改它? I'm sorry if this question is very basic because i am still new to this go.mod thing:(如果这个问题非常基本,我很抱歉,因为我对这个 go.mod 还是新手:(

If your git package has tag version, you can use this command:如果你的 git package 有tag版本,你可以使用这个命令:

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. -d表示“仅下载”,如果您想直接安装,请忽略此标志和此行下方的构建命令。
  • -v means "be verbose". -v表示“冗长”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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