[vscode-go] fix: check sdk binary existence concurrently

0 views
Skip to first unread message

Gerrit Bot (Gerrit)

unread,
5:02 AM (14 hours ago) 5:02 AM
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Gerrit Bot has uploaded the change for review

Commit message

fix: check sdk binary existence concurrently

Previously, getSDKGoOptions would blindly list all subdirectories in
the sdk directory as valid Go versions. This caused issues when files
like .DS_Store were present.

This change modifies getSDKGoOptions to verify that the 'go' binary
exists within the expected path for each subdirectory. It performs
these checks concurrently for better performance.
Change-Id: I0fa1aedf882adca58405083a8876ec8ac2cbeb1b
GitHub-Last-Rev: e65f3e229874a3a31cda09dedb7bec9f7dcff824
GitHub-Pull-Request: golang/vscode-go#3973

Change diff

diff --git a/extension/src/goEnvironmentStatus.ts b/extension/src/goEnvironmentStatus.ts
index 31d5d8d..4ed4203 100644
--- a/extension/src/goEnvironmentStatus.ts
+++ b/extension/src/goEnvironmentStatus.ts
@@ -466,12 +466,23 @@
}
const readdir = promisify(fs.readdir);
const subdirs = await readdir(sdkPath);
+ const stat = promisify(fs.stat);
+
// The dir happens to be the version, which will be used as the label.
// The path is assembled and used as the description.
- return subdirs.map(
- (dir: string) =>
- new GoEnvironmentOption(path.join(sdkPath, dir, 'bin', correctBinname('go')), dir.replace('go', 'Go '))
+ const options = await Promise.all(
+ subdirs.map(async (dir) => {
+ const binpath = path.join(sdkPath, dir, 'bin', correctBinname('go'));
+ try {
+ if ((await stat(binpath)).isFile()) {
+ return new GoEnvironmentOption(binpath, dir.replace('go', 'Go '));
+ }
+ } catch {
+ // ignore
+ }
+ })
);
+ return options.filter(Boolean) as GoEnvironmentOption[];
}

export async function getDefaultGoOption(): Promise<GoEnvironmentOption | undefined> {

Change information

Files:
  • M extension/src/goEnvironmentStatus.ts
Change size: S
Delta: 1 file changed, 14 insertions(+), 3 deletions(-)
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: vscode-go
Gerrit-Branch: master
Gerrit-Change-Id: I0fa1aedf882adca58405083a8876ec8ac2cbeb1b
Gerrit-Change-Number: 736765
Gerrit-PatchSet: 1
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Gopher Robot (Gerrit)

unread,
5:02 AM (14 hours ago) 5:02 AM
to Gerrit Bot, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Gopher Robot added 1 comment

Patchset-level comments
File-level comment, Patchset 1 (Latest):
Gopher Robot . unresolved

I spotted some possible problems with your PR:

  1. You usually need to reference a bug number for all but trivial or cosmetic fixes. For the vscode-go repo, the format is usually 'Fixes golang/vscode-go#1234' or 'Updates golang/vscode-go#1234' at the end of the commit message. Should you have a bug reference?

Please address any problems by updating the GitHub PR.

When complete, mark this comment as 'Done' and click the [blue 'Reply' button](https://go.dev/wiki/GerritBot#i-left-a-reply-to-a-comment-in-gerrit-but-no-one-but-me-can-see-it) above. These findings are based on heuristics; if a finding does not apply, briefly reply here saying so.

To update the commit title or commit message body shown here in Gerrit, you must edit the GitHub PR title and PR description (the first comment) in the GitHub web interface using the 'Edit' button or 'Edit' menu entry there. Note: pushing a new commit to the PR will not automatically update the commit message used by Gerrit.

For more details, see:

(In general for Gerrit code reviews, the change author is expected to [log in to Gerrit](https://go-review.googlesource.com/login/) with a Gmail or other Google account and then close out each piece of feedback by marking it as 'Done' if implemented as suggested or otherwise reply to each review comment. See the [Review](https://go.dev/doc/contribute#review) section of the Contributing Guide for details.)

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: vscode-go
    Gerrit-Branch: master
    Gerrit-Change-Id: I0fa1aedf882adca58405083a8876ec8ac2cbeb1b
    Gerrit-Change-Number: 736765
    Gerrit-PatchSet: 1
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-Comment-Date: Sat, 17 Jan 2026 10:02:49 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages