我用 gin-gonic对于我的休息 API。
我有一个问题。
最新标签是v1.6.3
但在 master
分支有一种我想使用的方法。
我在 go.mod
中输入了什么使用 master
分支而不是最新的标签?
笔记:
CustomRecovery()
master
中可用的方法分支,但不在 v1.6.3
中更新:
这是我的 go.mod
go 1.15
require (
github.com/gin-gonic/gin 16cd8cdd4ef9
)
但是当我运行 go mod download 时,它会自动更改为此
go 1.15
require (
github.com/gin-gonic/gin v1.6.3-0.20201025090830-16cd8cdd4ef9
github.com/joho/godotenv v1.3.0
gorm.io/driver/mysql v1.0.3
gorm.io/gorm v1.20.5
)
它正在工作。
最佳答案
这应该可以通过遵循文档“How to Upgrade and Downgrade Dependencies
一个简单的go get example.com/package
修改 go.mod 并使用特定依赖项的最新版本就足够了。
要将依赖项及其所有依赖项升级到最新版本:
go get -u example.com/package
那是:
go get foo
updates to the latest version offoo
.
go get foo
is equivalent togo get foo@latest
— in other words,@latest
is the default if no@
version is specified.
和:
A common mistake is thinking
go get -u foo
solely gets the latest version offoo
.
In actuality, the-u
ingo get -u foo
orgo get -u foo@latest
means to also get the latest versions for all of the direct and indirect dependencies offoo
.A common starting point when upgrading foo is instead to do
go get foo
orgo get foo@latest
without a-u
(and after things are working, considergo get -u=patch foo
,go get -u=patch
,go get -u foo
, orgo get -u
).
关于go.mod 使用没有标签的模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64549973/