@@ -11,7 +11,6 @@ import (
1111 "os"
1212 "os/exec"
1313 "path/filepath"
14- "strings"
1514 "time"
1615)
1716
@@ -177,11 +176,7 @@ func runGo(ctx context.Context, job *Job) (err error) {
177176 // A Cmd with a non-empty Dir field and nil Env now implicitly sets the PWD environment variable for the subprocess to match Dir.
178177 // The new method Cmd.Environ reports the environment that would be used to run the command, including the implicitly set PWD variable.
179178 // cmd.Env = append(cmd.Environ(), "PORT="+job.Port) // requires go 1.19
180- var host = job.Host
181- if strings.Contains(host, ":") {
182- host = fmt.Sprintf("[%s]", host)
183- }
184- cmd.Env = append(cmd.Env, "LISTEN_ADDRESS="+host+":"+job.Port, "PWD="+cmd.Dir)
179+ cmd.Env = append(cmd.Env, "LISTEN_ADDRESS="+net.JoinHostPort(job.Host, job.Port), "PWD="+cmd.Dir)
185180
186181 // Running asynchronously allows for the client Run method to return
187182 // metadata about the running function such as its chosen port.
@@ -273,7 +268,7 @@ func runPython(ctx context.Context, job *Job) (err error) {
273268
274269func waitFor(ctx context.Context, job *Job, timeout time.Duration) error {
275270 var (
276- uri = fmt.Sprintf("http://%s:%s%s ", job.Host, job.Port, readinessEndpoint)
271+ uri = fmt.Sprintf("http://%s%s ", net.JoinHostPort( job.Host, job.Port) , readinessEndpoint)
277272 interval = 500 * time.Millisecond
278273 )
279274
0 commit comments