Serge Bazanski | ab4ef13 | 2021-09-24 13:58:13 +0200 | [diff] [blame^] | 1 | // gotoolchain provides information about the Go toolchain used on the host by |
| 2 | // rules_go. |
| 3 | package gotoolchain |
| 4 | |
| 5 | import ( |
| 6 | "fmt" |
| 7 | |
| 8 | "github.com/bazelbuild/rules_go/go/tools/bazel" |
| 9 | ) |
| 10 | |
| 11 | func mustRunfile(s string) string { |
| 12 | res, err := bazel.Runfile(s) |
| 13 | if err != nil { |
| 14 | panic(fmt.Sprintf("runfile %q not found: %v", s, err)) |
| 15 | } |
| 16 | return res |
| 17 | } |
| 18 | |
| 19 | var ( |
| 20 | // Go is a path to the `go` executable. |
| 21 | Go = mustRunfile(`GOTOOL`) |
| 22 | // Root is the GOROOT path. |
| 23 | Root = mustRunfile(`GOROOT`) |
| 24 | ) |