extension/src: update regex for parseGoVersionOutput In the pickGoProcess feature, we provide an interactive process picker to find local processes to attach to in debug mode. We find and filter all local processes to determine which ones are actually Go. To do this, we run 'go version' on the executable paths. We then attempt to match the output of 'go version' to a regex goVersionRegexp. Currently, this regex does not match go versions with suffixes like "rc1" or "-X:nodwarf5, so it will not add them to the list of available processes to attach. Update the regex to allow these suffixes so that we show them in the pickGoProcess dropdown. Fixes golang/vscode-go#4059 Change-Id: I612bba3a9f5fa41e29db61f92e3f48e413660e05 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/803680 LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Hongxiang Jiang <hxjiang@golang.org>
diff --git a/extension/src/pickProcess.ts b/extension/src/pickProcess.ts index 45a6a30..2259788 100644 --- a/extension/src/pickProcess.ts +++ b/extension/src/pickProcess.ts
@@ -133,7 +133,7 @@ export function parseGoVersionOutput(stdout: string): string[] { const goProcessExes: string[] = []; - const goVersionRegexp = /: go\d+\.\d+(\.\d+)?$/; + const goVersionRegexp = /: go\d+\.\d+(\.\d+)?.*$/; const lines = stdout.toString().split('\n'); lines.forEach((line) => {
diff --git a/extension/test/integration/pickProcess.test.ts b/extension/test/integration/pickProcess.test.ts index 7bba8ee..c961e7f 100644 --- a/extension/test/integration/pickProcess.test.ts +++ b/extension/test/integration/pickProcess.test.ts
@@ -33,6 +33,11 @@ input: '/path/to/process/a: go11a62b12\n/path/to/process/b: go1/15/4\n/path/to/process/a b c: gob.v.b\n/path/to/process/d: gp1.14', want: [] + }, + { + // Match go versions with custom suffixes like "X:nodwarf5" or "rc1". + input: '/path/to/process/a: go1.26.5-X:nodwarf5\n/path/to/process/b: go1.22rc1', + want: ['/path/to/process/a', '/path/to/process/b'] } ]; for (const tc of tt) {