Source:
public void build(@NotNull GoTarget target, @NotNull DirtyFilesHolder<GoSourceRootDescriptor, GoTarget> holder, @NotNull BuildOutputConsumer outputConsumer, @NotNull CompileContext context) throws ProjectBuildException, IOException { LOG.debug(target.getPresentableName()); if (!holder.hasDirtyFiles() && !holder.hasRemovedFiles()) return; JpsModule jpsModule = target.getModule(); if (jpsModule.getModuleType() != JpsGoModuleType.INSTANCE) return; JpsTypedModule<JpsSimpleElement<JpsGoModuleProperties>> module = jpsModule.asTyped(JpsGoModuleType.INSTANCE); assert module != null; JpsSdk<JpsDummyElement> sdk = getSdk(context, module); File exec = GoEnvironmentUtil.getExecutableForSdk(sdk.getHomePath()); if (exec == null) { Notifications.Bus.notify( new Notification("Go", "Something went wrong with `go run`", "go tool executable could not be found in the sdk home", NotificationType.WARNING) ); return; } String executable = exec.getAbsolutePath(); File outputDirectory = getBuildOutputDirectory(module, target.isTests(), context); for (String contentRootUrl : module.getContentRootsList().getUrls()) { String contentRootPath = new URL(contentRootUrl).getPath(); GeneralCommandLine commandLine = new GeneralCommandLine(); commandLine.getEnvironment().put(GoConstants.GO_PATH, JpsGoLibrariesExtensionService.getInstance().retrieveGoPath(module)); commandLine.withWorkDirectory(contentRootPath); commandLine.setExePath(executable); commandLine.addParameter("build"); String outExecutable = GoEnvironmentUtil.getExecutableResultForModule(contentRootPath, outputDirectory.getAbsolutePath()); commandLine.addParameters("-o", FileUtil.toSystemDependentName(outExecutable)); runBuildProcess(context, commandLine, contentRootPath); } }

Target:
public void build(@NotNull GoTarget target, @NotNull DirtyFilesHolder<GoSourceRootDescriptor, GoTarget> holder, @NotNull BuildOutputConsumer outputConsumer, @NotNull CompileContext context) throws ProjectBuildException, IOException { LOG.debug(target.getPresentableName()); if (!holder.hasDirtyFiles() && !holder.hasRemovedFiles()) return; JpsModule jpsModule = target.getModule(); if (jpsModule.getModuleType() != JpsGoModuleType.INSTANCE) return; JpsTypedModule<JpsSimpleElement<JpsGoModuleProperties>> module = jpsModule.asTyped(JpsGoModuleType.INSTANCE); assert module != null; JpsSdk<JpsDummyElement> sdk = getSdk(context, module); File executable = GoEnvironmentUtil.getExecutableForSdk(sdk.getHomePath()); File outputDirectory = getBuildOutputDirectory(module, target.isTests(), context); for (String contentRootUrl : module.getContentRootsList().getUrls()) { String contentRootPath = new URL(contentRootUrl).getPath(); GeneralCommandLine commandLine = new GeneralCommandLine(); commandLine.getEnvironment().put(GoConstants.GO_PATH, JpsGoLibrariesExtensionService.getInstance().retrieveGoPath(module)); commandLine.withWorkDirectory(contentRootPath); commandLine.setExePath(executable.getAbsolutePath()); commandLine.addParameter("build"); String outExecutable = GoEnvironmentUtil.getExecutableResultForModule(contentRootPath, outputDirectory.getAbsolutePath()); commandLine.addParameters("-o", FileUtil.toSystemDependentName(outExecutable)); runBuildProcess(context, commandLine, contentRootPath); } }