From a90a80c5014201c4542a6fd057101f984634a89f Mon Sep 17 00:00:00 2001 From: Christian Banse Date: Tue, 19 Sep 2023 23:57:20 +0200 Subject: [PATCH] Adding GOOS and GOARCH to buildProject --- .../fraunhofer/aisec/cpg/frontends/golang/GoUtils.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cpg-language-go/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/golang/GoUtils.kt b/cpg-language-go/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/golang/GoUtils.kt index 9408540025..a06a2471b5 100644 --- a/cpg-language-go/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/golang/GoUtils.kt +++ b/cpg-language-go/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/golang/GoUtils.kt @@ -179,11 +179,16 @@ internal class Project { val topLevel = File(modulePath) - var proc = - ProcessBuilder("go", "list", "all") + val pb = + ProcessBuilder("go", "list", tags.joinToString(",", "-tags="), "all") .directory(topLevel) .redirectOutput(ProcessBuilder.Redirect.PIPE) - .start() + + val env = pb.environment() + env["GOOS"] = goos + env["GOARCH"] = goarch + + var proc = pb.start() proc.waitFor(5, TimeUnit.MINUTES) if (proc.exitValue() != 0) { log.debug(proc.errorStream.bufferedReader().readLine())