When tests are ran the -trimpath flag runtime.GOROOT() returns an empty string. This causes TestOSExitNotAllowed to fail because build.Context.ImportDir() cannot find packages in the standard library (without GOROOT it does not know where to look - see issue https://github.com/junegunn/fzf/issues/3748). This commit fixes that by falling back to go env GOROOT if runtime.GOROOT() returns an empty string. This works because go env GOROOT performs more work to identify the GOROOT than runtime.GOROOT().
When tests are ran the
-trimpath
flagruntime.GOROOT()
returns an empty string. This causesTestOSExitNotAllowed
to fail becausebuild.Context.ImportDir()
cannot find packages in the standard library (without GOROOT it does not know where to look - see issue https://github.com/junegunn/fzf/issues/3748). This commit fixes that by falling back togo env GOROOT
ifruntime.GOROOT()
returns an empty string. This works becausego env GOROOT
performs more work to identify the GOROOT thanruntime.GOROOT()
.This should fix https://github.com/junegunn/fzf/issues/3748.