os/exec.Command returns a Cmd with only Path and Args filled out.
That means that doing
cmd := exec.Command("foo")
cmd.Env = append(cmd.Env, "FOO=bar")
is always equivalent to
cmd := exec.Command("foo")
cmd.Env = []string{"FOO=bar"}
but almost certainly intended to be
cmd := exec.Command("foo")
cmd.Env = append(cmd.Environ(), "FOO=bar")
instead.
I introduced this bug at least a couple times in the standard library tests.
os/exec.Command returns a Cmd with only Path and Args filled out.
That means that doing
is always equivalent to
but almost certainly intended to be
instead.
I introduced this bug at least a couple times in the standard library tests.