go.mod 使用没有标签的模块

标签 go go-gin go-modules go-get

我用 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 of foo.
    go get foo is equivalent to go 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 of foo.
    In actuality, the -u in go get -u foo or go get -u foo@latest means to also get the latest versions for all of the direct and indirect dependencies of foo.

    A common starting point when upgrading foo is instead to do go get foo or go get foo@latest without a -u (and after things are working, consider go get -u=patch foo, go get -u=patch, go get -u foo, or go get -u).

    关于go.mod 使用没有标签的模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64549973/

    相关文章:

    go - 构建一个多可执行的 Go 项目

    javascript - 在以太坊区 block 链上保存合约数据的更有效方式是什么?

    mysql - 使用 GORM for Golang 的一对一关系映射

    go - 如何使用 Go Google SDK 模拟用户?

    json - Golang slice 的结构或新手在构建 REST 时遇到麻烦

    Golang 模块问题--package xxx/xxxx is not in GOROOT

    go - Golang Go使用错误的URL @ Go 1.13使用git ls-remote -q失败

    google-app-engine - 在 App Engine 上返回 Gzip 压缩的响应主体

    go - 如何测试表格提交

    unit-testing - 使用 Gin-Gonic 进行单元测试