From 6fa81713db35f7d1d9c8fc2b9c2eb1f6ba97adf1 Mon Sep 17 00:00:00 2001 From: Jeremy Fleitz Date: Fri, 11 Sep 2026 11:48:25 -0400 Subject: [PATCH 1/2] get go bin path from go and support symlink Signed-off-by: Jeremy Fleitz --- src/utils.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/utils.rs b/src/utils.rs index 883bc69..a767b0e 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -274,10 +274,25 @@ pub fn check_go_version(go_path: &Path) -> Result<()> { } } + +// go_root() returns `None` if the `go` binary cannot be executed or does not return a valid `GOROOT`. +fn go_root(go: &Path) -> Option { + let output = Command::new(go).args(["env", "GOROOT"]).output().ok()?; + if !output.status.success() { + return None; + } + let root = String::from_utf8(output.stdout).ok()?; + let root = root.trim(); + if root.is_empty() { + None + } else { + Some(PathBuf::from(root)) + } +} + fn check_go_async_support(go: &Path) -> Option<()> { fs::read_to_string( - go.parent()? - .parent()? + go_root(go)? .join("src") .join("runtime") .join("lock_wasip1.go"), From 3b2edfc226f42ec8e208e922e314e68440db6a3b Mon Sep 17 00:00:00 2001 From: Jeremy Fleitz Date: Fri, 11 Sep 2026 11:52:15 -0400 Subject: [PATCH 2/2] lint fix Signed-off-by: Jeremy Fleitz --- src/utils.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/utils.rs b/src/utils.rs index a767b0e..83c1398 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -274,7 +274,6 @@ pub fn check_go_version(go_path: &Path) -> Result<()> { } } - // go_root() returns `None` if the `go` binary cannot be executed or does not return a valid `GOROOT`. fn go_root(go: &Path) -> Option { let output = Command::new(go).args(["env", "GOROOT"]).output().ok()?;