On Thursday, 11 August 2022 at 10:09:35 UTC+2 Jan Mercl wrote:
> On Thu, Aug 11, 2022 at 9:59 AM Patrick Smith <pat42...@gmail.com> wrote: > > > To date, I've been using a recipe I found some time ago through an > Internet search (I've forgotten the source, so can't credit it): > > > > gocmd := runtime.GOROOT() + "/bin/go" > > if runtime.GOOS == "windows" { > > gocmd += ".exe" > > } > > I think using https://pkg.go.dev/os/exec#LookPath would be more > correct as it respects the environment of the current process. > exec.LookPath is even better in Go 1.19, which implements "go test and go generate now place GOROOT/bin at the beginning of the PATH used for the subprocess, so tests and generators that execute the go command will resolve it to same GOROOT."[0] Elias [0] https://tip.golang.org/doc/go1.19#go-command -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/944a6700-b7e7-44a3-b3aa-047cd1b96601n%40googlegroups.com.