Home >Backend Development >Golang >How Can I Use `go get` to Retrieve a Specific Branch of a Go Module Dependency?
Retrieving a Specific Branch Using Go Get
When using Go modules, you can retrieve a specific branch of a dependency rather than the default master branch.
To achieve this, you can utilize the go get command with a module query that includes the branch name. For instance:
$ go get <path-to-repo>@<branch>
In your scenario, you have two repositories, repo_a and repo_b, with repo_a imported into repo_b. To obtain the develop branch of repo_a instead of the master branch, you can execute the following command in repo_b:
$ go get <path-to-repo_a>@develop
This will install the develop branch of repo_a into your Go module.
Please note that this approach requires Go 1.11 or later, as support for specifying branches in module queries was introduced in that version.
The above is the detailed content of How Can I Use `go get` to Retrieve a Specific Branch of a Go Module Dependency?. For more information, please follow other related articles on the PHP Chinese website!