gitgithubgo

How to get another branch instead of default branch with go get


I have 2 repositories. Let say them repo_a and repo_b. I imported repo_a in repo_b

When I ran go get, it will get repo_a master branch. Is there any way to get develop branch using go get or another command from repo_b?

I do not want to git pull on each specific package (in this case repo_a)


Solution

  • Starting with Go 1.11, this is possible when using Go modules. When installing a dependency for a Go module, you can specify a module query which may contain a branch or tag name:

    $ go get <path-to-repo>@<branch>