in pkg/golang/install.go [39:79]
func InstallGoVersions(rules *config.RepositoryRules) error {
if rules == nil {
return nil
}
defaultGoVersion := deprecatedDefaultGoVersion
if rules.DefaultGoVersion != nil {
defaultGoVersion = *rules.DefaultGoVersion
}
glog.Infof("Using %s as the default go version", defaultGoVersion)
goVersions := []string{defaultGoVersion}
for _, rule := range rules.Rules {
for _, branch := range rule.Branches {
if branch.GoVersion != "" {
found := false
for _, v := range goVersions {
if v == branch.GoVersion {
found = true
}
}
if !found {
goVersions = append(goVersions, branch.GoVersion)
}
}
}
}
systemGoPath := os.Getenv("GOPATH")
for _, v := range goVersions {
if err := installGoVersion(v, filepath.Join(systemGoPath, "go-"+v)); err != nil {
return err
}
}
goLink, target := filepath.Join(systemGoPath, "go"), filepath.Join(systemGoPath, "go-"+defaultGoVersion)
os.Remove(goLink)
if err := os.Symlink(target, goLink); err != nil {
return fmt.Errorf("failed to link %s to %s: %s", goLink, target, err)
}
return nil
}