src/util.ts: fix go version output parsing
We need to use the matched group for version and commit hash,
not the entire matched go version output.
Change-Id: I8688bb721c5d9914868f4611d87361e7ffe4157b
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/245397
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
diff --git a/src/util.ts b/src/util.ts
index 0274b7d..9684d9f 100644
--- a/src/util.ts
+++ b/src/util.ts
@@ -89,13 +89,13 @@
const matchesRelease = /go version go(\d.\d+).*/.exec(version);
const matchesDevel = /go version devel \+(.[a-zA-Z0-9]+).*/.exec(version);
if (matchesRelease) {
- const sv = semver.coerce(matchesRelease[0]);
+ const sv = semver.coerce(matchesRelease[1]);
if (sv) {
this.sv = sv;
}
} else if (matchesDevel) {
this.isDevel = true;
- this.commit = matchesDevel[0];
+ this.commit = matchesDevel[1];
}
}
@@ -318,7 +318,7 @@
if (cachedGoVersion.isValid()) {
return Promise.resolve(cachedGoVersion);
}
- warn(`cached Go version (${cachedGoVersion}) is invalid, recomputing`);
+ warn(`cached Go version (${JSON.stringify(cachedGoVersion)}) is invalid, recomputing`);
}
try {
const execFile = util.promisify(cp.execFile);