How can I get master branch of a dependency when using Go modules
Asked Answered
I

1

5

I am using Go-modules for a project. When I retrieve the dependency for a package, it retrieves an old release. How can I get the code in the master branch?

Ic answered 1/6, 2019 at 16:26 Comment(3)
What command are you using? Specifying master will get master, though the synthetic version generated in go.mod may appear to reference an older tag. Just check the commit hash itself.Dela
It looks like go modules retrieve an old tag for one of the deps in my project. I used go get to get the master branch and go.mod files gets updated automatically.Ic
What was the exact command? If you want master, did you specify that in the command?Dela
N
16

Use:

go get foo@master
go get [email protected]    //for v1.2.3 tag
go get foo@master    // for master
go get foo@e3702bed2 // for a specific commit

There are some more details about versioning here:

https://github.com/golang/go/wiki/Modules#daily-workflow

Nucleotide answered 1/6, 2019 at 20:7 Comment(1)
branches are not working in go v1.15.3: github.com/golang/go/issues/37438Postfix

© 2022 - 2024 — McMap. All rights reserved.