Acquiring Non-Default Branches in Go with go get
In a software development workflow involving multiple repositories, situations may arise where specific branches, rather than the default master branch, need to be retrieved. This question centers around accessing the develop branch of a dependency repository from within another repository.
Solution using Go Modules
With the advent of Go modules in Go 1.11, retrieving specific branches of dependencies became feasible. Go modules utilize module queries, which allow for the specification of branches or tags during dependency installation.
To retrieve the develop branch of a dependency repository named repo_a from within your own repository repo_b, simply include the branch name in the module query when executing go get:
$ go get <path-to-repo_a>@<branch-name>
For instance:
$ go get example.com/repo_a@develop
The above is the detailed content of How Can I Use `go get` to Fetch Non-Default Branches in Go Modules?. For more information, please follow other related articles on the PHP Chinese website!