blob: 907a719c1aee3eec4c6fac85aa878b481309dc2f [file] [log] [blame]
package go_install
This package aids in obtaining an installation of Go from CIPD.
import (
// EnsureGo ensures that the Go installation is obtained from CIPD at the
// correct version and returns the path to the go binary and the relevant
// environment variables or any errors which occurred. If includeDeps is true,
// also installs the go_deps CIPD package which contains all dependencies for
// the repository as of the last update of that package.
func EnsureGo(ctx context.Context, client *http.Client, cipdRoot string) (string, map[string]string, error) {
pkgs := []*cipd.Package{cipd.PkgGo}
if err := cipd.Ensure(ctx, client, cipdRoot, pkgs...); err != nil {
return "", nil, fmt.Errorf("Failed to ensure Go CIPD package: %s", err)
goRoot := path.Join(cipdRoot, cipd.PkgGo.Path, "go")
goBin := path.Join(goRoot, "bin")
return path.Join(goBin, "go"), map[string]string{
"GO111MODULE": "on",
"GOROOT": goRoot,
"PATH": goBin,
}, nil