Skip to content

Commit 7bd8399

Browse files
authored
magetasks: Set GOTOOLCHAIN=auto when installing Golang dependencies (#40)
build: Set GOTOOLCHAIN=auto when installing dependencies Set the `GOTOOLCHAIN` environment variable to "auto" when running `go install` for dependencies. This leverages the Go 1.21+ feature to automatically download and use the Go toolchain version specified in the dependency's `go.mod` file. This improves build reproducibility and simplifies environment setup by removing the need to have a specific Go version pre-installed.
1 parent e9fe9e8 commit 7bd8399

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

magetasks/config/deps.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ func (d dependencies) Install(_ context.Context, t *tasks.Task, dest string) err
5757
for _, dep := range d.installs() {
5858
pp := t.Part(fmt.Sprintf("Go install %q", dep)).Starting()
5959
env := map[string]string{
60-
"GOBIN": dest,
60+
"GOBIN": dest,
61+
"GOTOOLCHAIN": "auto",
6162
}
6263
if err := sh.RunWith(env, "go", "install", dep); err != nil {
6364
pp.Done(err)

0 commit comments

Comments
 (0)