Oh and also, FYI, os.Setenv("GOROOT") will *not* work, because 
runtime.GOROOT() does *not* look at the current environment, it caches the 
GOROOT from when the binary first started up... which makes sense, but its 
docs confusingly say it looks at the environment, which is does, but not 
the *current* environment.   

On Monday, October 16, 2017 at 11:59:30 PM UTC-4, Nate Finch wrote:
>
> So I figured out I was looking for the error in the wrong place.  The 
> place it was failing was in go/types when it tries to parse the files, 
> using the go/build.Default context.  Which is created here: 
> https://github.com/golang/go/blob/master/src/go/build/build.go#L285
>
> It uses either the GOROOT of the environment (which is invariably not 
> set), or the GOROOT of the machine that built this binary.
>
> Thanks to Dave, no one ever sets GOROOT, and so it defaults to the one 
> from my OSX machine where I built the binary.  aaarrggg
>
> So the fix is to call go env GOROOT and use that to set the GOROOT on 
> build.Default and then it'll actually do the right thing.  Just in case 
> anyone else ever hits this. (Hello me from the future!  You're welcome!)
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to