Re: [go-nuts] Finding the go command from inside a test case

2022-08-11 Thread Patrick Smith
On Thu, Aug 11, 2022 at 3:19 AM ma...@eliasnaur.com wrote: > 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

Re: [go-nuts] Finding the go command from inside a test case

2022-08-11 Thread ma...@eliasnaur.com
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 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()

Re: [go-nuts] Finding the go command from inside a test case

2022-08-11 Thread Jan Mercl
On Thu, Aug 11, 2022 at 9:59 AM Patrick Smith 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" { >

[go-nuts] Finding the go command from inside a test case

2022-08-11 Thread Patrick Smith
I sometimes find that I want to run the go command from inside a test case, for example to build generated code, or to verify that code that should raise an error at compile time does in fact cause that error. That raises the question, is there a reliable way to find the go command from inside a t