go get
retrieves the default branch of the package by default. This is often using the master
branch. But the master
branch is including work in progress code sometimes, so want to avoid to use it.
To solve this problem, there is an approach of dividing the default branch and the development branch. But this is just a little complex.
Other approaches to solving this problem, use a branch or tag named go1
.
go get
has a rule for looks for a branch of tag that matches the locally installed version of Go. It describes in the doc.
When checking out or updating a package, get looks for a branch or tag that matches the locally installed version of Go. The most important rule is that if the local installation is running version "go1", get searches for a branch or tag named "go1". If no such version exists it retrieves the default branch of the package.
https://golang.org/cmd/go/#hdr-Download_and_install_packages_and_dependencies
This is also can confirm in get.go
. Below is the code of the corresponding part.
// selectTag returns the closest matching tag for a given version.
// Closest means the latest one that is not after the current release.
// Version "goX" (or "goX.Y" or "goX.Y.Z") matches tags of the same form.
// Version "release.rN" matches tags of the form "go.rN" (N being a floating-point number).
// Version "weekly.YYYY-MM-DD" matches tags like "go.weekly.YYYY-MM-DD".
//
// NOTE(rsc): Eventually we will need to decide on some logic here.
// For now, there is only "go1". This matches the docs in go help get.
func selectTag(goVersion string, tags []string) (match string) {
for _, t := range tags {
if t == "go1" {
return "go1"
}
}
return ""
}
Unfortunately, we can use go1
tar or branch only now.
But can use go1
to control the version used. Let's try to use it.
Top comments (1)
A possible alternative is to use the new "modules" feature and point to any version you like:
Go get(s) modules
rhymes