gogo-gingo-modulesgo-get

go.mod use modules without tags


I use gin-gonic for my rest API.

I have a problem with it.

The latest tag is v1.6.3 but in master branch there is a method that I want to use.

What do I put in the go.mod to use the master branch instead the latest tag?

Note:

Update:

Here is my go.mod

go 1.15

require (
    github.com/gin-gonic/gin 16cd8cdd4ef9
)

but when I run go mod download it changes automatically to this


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
)

And it's working.


Solution

  • This should be possible by following the documentation "How to Upgrade and Downgrade Dependencies

    A simple go get example.com/package is enough to modify the go.mod and use the latest version of a specific dependency.
    To upgrade a dependency and all its dependencies to the latest version:

    go get -u example.com/package
    

    That is:

    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.

    And:

    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).