feat: support FUNC_GO env in Host builder (#2877)

This commit is contained in:
Luke Kingland 2025-06-30 16:50:10 +09:00 committed by GitHub
parent 243059b25b
commit ec66c1a496
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 13 additions and 2 deletions

View File

@ -113,6 +113,16 @@ func getRunFunc(ctx context.Context, job *Job) (runFn func() error, err error) {
}
func runGo(ctx context.Context, job *Job) (err error) {
// TODO: long-term, the correct architecture is to not read env vars
// from deep within a package, but rather to expose the setting as a
// variable and leave interacting with the environment to main.
// This is a shortcut used by many packages, however, so it will work for
// now.
gobin := os.Getenv("FUNC_GO") // Use if provided
if gobin == "" {
gobin = "go" // default to looking on PATH
}
// BUILD
// -----
// TODO: extract the build command code from the OCI Container Builder
@ -125,7 +135,7 @@ func runGo(ctx context.Context, job *Job) (err error) {
if job.verbose {
args = append(args, "-v")
}
cmd := exec.CommandContext(ctx, "go", args...)
cmd := exec.CommandContext(ctx, gobin, args...)
cmd.Dir = job.Dir()
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
@ -139,7 +149,8 @@ func runGo(ctx context.Context, job *Job) (err error) {
if job.verbose {
args = append(args, "-v")
}
cmd = exec.CommandContext(ctx, "go", args...)
cmd = exec.CommandContext(ctx, gobin, args...)
cmd.Dir = job.Dir()
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr