command.setExePath(goCommand);
command.addParameter("env");
command.withWorkDirectory(path);
command.getEnvironment().put("GOROOT", path);
ProcessOutput output = new CapturingProcessHandler(
command.createProcess(),
Charset.defaultCharset(),
command.getCommandLineString()).runProcess();
if (output.getExitCode() != 0) {
LOG.error(
format(
"%s env command exited with invalid exit code: %d",
goCommand, output.getExitCode()));
return null;
}
String outputString = output.getStdout();
Matcher matcher;
matcher = RE_HOSTOS_MATCHER.matcher(outputString);
if (matcher.find()) {
data.TARGET_OS = GoTargetOs.fromString(matcher.group(1));