Search code examples
gogo-modules

Update the library to a specific version


This is the version of golang.org/x/net library I am using

golang.org/x/net v0.0.0-20181005035420-146acd28ed58

v0.0.0 is a release(it means there is no release) 20181005 is the time for commit 146acd28ed58- short for commit id what is 035420 in the middle of the version? The issue I want to upgrade this library to

https://github.com/golang/net/commit/7e3656a0809f6f95abd88ac65313578f80b00df2

So I derived the following part:

   golang.org/x/net v0.0.0-20200506       -7e3656a0809f

I can't find what should be in the middle?


Solution

  • Go Wiki: Modules: How to Upgrade and Downgrade Dependencies:

    To upgrade or downgrade to a more specific version, 'go get' allows version selection to be overridden by adding an @version suffix or "module query" to the package argument, such as go get foo@v1.6.2, go get foo@e3702bed2, or go get foo@'<v1.6.2'.

    So in your case just run:

    go get golang.org/x/net@7e3656a0809f6f95abd88ac65313578f80b00df2
    

    See related: Go modules pulls old version of a package