goInstallTools: show PATH entries when go is missing
Problem
When the extension cannot find the go binary, the existing prompt points
users to install Go but does not help diagnose PATH mismatches inside VS
Code. Instead, it shows a very disruptive blog of paths that is usually cutoff
as it does not fit the notification UI.
Change
This change updates the missing-go prompt to offer a "Show PATH Entries"
action alongside the download link.
The PATH action opens a quick pick with the PATH entries searched for the
go binary. This makes it easier to spot missing or unexpected
directories.
The prompt message is also trimmed to report GOROOT separately and avoid
dumping the full PATH into the error text.
Implementation
The choice handling is split into small local helpers in
goInstallTools.ts. Brief comments are also added for the new prompt
actions and the PATH parsing helper.
Testing
Tested with npm run bundle-dev
diff --git a/extension/src/goInstallTools.ts b/extension/src/goInstallTools.ts
index 97cd781..9ea8365 100644
--- a/extension/src/goInstallTools.ts
+++ b/extension/src/goInstallTools.ts
@@ -720,21 +720,63 @@
let suggestedDownloadGo = false;
-async function suggestDownloadGo() {
- const msg =
- `Failed to find the "go" binary in either GOROOT(${getCurrentGoRoot()}) or PATH(${getEnvPath()}). ` +
- 'Check PATH, or Install Go and reload the window. ' +
- "If PATH isn't what you expected, see https://github.com/golang/vscode-go/issues/971";
+// Actions shown when the extension cannot locate the go binary.
+const SHOW_PATH_ENTRIES_ACTION = 'Show PATH Entries';
+const GO_DOWNLOAD_PAGE_ACTION = 'Go to Download Page';
+const GO_DOWNLOAD_URL = 'https://golang.org/dl/';
- if (suggestedDownloadGo) {
- vscode.window.showErrorMessage(msg);
+// Split PATH using the platform delimiter and drop empty entries for display.
+function getPathEntries(): string[] {
+ return (getEnvPath() ?? '')
+ .split(path.delimiter)
+ .map((entry: string) => entry.trim())
+ .filter(Boolean);
+}
+
+async function handleDownloadGoChoice(choice: string | undefined): Promise<void> {
+ if (choice === SHOW_PATH_ENTRIES_ACTION) {
+ await showPathEntriesQuickPick();
return;
}
- const choice = await vscode.window.showErrorMessage(msg, 'Go to Download Page');
- if (choice === 'Go to Download Page') {
- vscode.env.openExternal(vscode.Uri.parse('https://golang.org/dl/'));
+ if (choice === GO_DOWNLOAD_PAGE_ACTION) {
+ await vscode.env.openExternal(vscode.Uri.parse(GO_DOWNLOAD_URL));
}
+ return;
+}
+
+async function showPathEntriesQuickPick() {
+ const pathEntries = getPathEntries();
+
+ if (!pathEntries.length) {
+ await vscode.window.showInformationMessage('PATH is empty.');
+ return;
+ }
+
+ await vscode.window.showQuickPick(pathEntries, {
+ title: 'PATH Entries Searched for go',
+ placeHolder: 'Entries from PATH used when searching for the go binary',
+ ignoreFocusOut: true
+ });
+}
+
+async function suggestDownloadGo() {
+ const goRoot = getCurrentGoRoot() ?? '(not set)';
+ const message =
+ `Failed to find the "go" binary in either GOROOT(${goRoot}) or PATH. ` +
+ 'Check PATH, or install Go and reload the window.';
+ const choice = await vscode.window.showErrorMessage(
+ message,
+ SHOW_PATH_ENTRIES_ACTION,
+ GO_DOWNLOAD_PAGE_ACTION
+ );
+
+ if (suggestedDownloadGo) {
+ await handleDownloadGoChoice(choice);
+ return;
+ }
+
+ await handleDownloadGoChoice(choice);
suggestedDownloadGo = true;
}
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
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.)
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Congratulations on opening your first change. Thank you for your contribution!
Next steps:
A maintainer will review your change and provide feedback. See
https://go.dev/doc/contribute#review for more info and tips to get your
patch through code review.
Most changes in the Go project go through a few rounds of revision. This can be
surprising to people new to the project. The careful, iterative review process
is our way of helping mentor contributors and ensuring that their contributions
have a lasting impact.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
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:
- [how to update commit messages](https://go.dev/wiki/GerritBot/#how-does-gerritbot-determine-the-final-commit-message) for PRs imported into Gerrit.
- the Go project's [conventions for commit messages](https://go.dev/doc/contribute#commit_messages) that you should follow.
(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.)
There should not be a bug reference, this is a mostly cosmetic change with a slight redesign of existing behavior. There is no fundamental change to what this feature originally intended. It’s just been made a bit more user friendly.
It also seems that the checks in my PR are breaking due to unrelated changes:
2026/05/04 14:27:16 unknown type "int64"
This build error does not reproduce locally and seems caused by the introduction of Go 1.26
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Tarik C. BrownI 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:
- [how to update commit messages](https://go.dev/wiki/GerritBot/#how-does-gerritbot-determine-the-final-commit-message) for PRs imported into Gerrit.
- the Go project's [conventions for commit messages](https://go.dev/doc/contribute#commit_messages) that you should follow.
(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.)
There should not be a bug reference, this is a mostly cosmetic change with a slight redesign of existing behavior. There is no fundamental change to what this feature originally intended. It’s just been made a bit more user friendly.
It also seems that the checks in my PR are breaking due to unrelated changes:
2026/05/04 14:27:16 unknown type "int64"This build error does not reproduce locally and seems caused by the introduction of Go 1.26
Done
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Commit-Queue | +1 |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
I believe you'll need to rebase this CL on the master branch in order for the tests to pass
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
I believe you'll need to rebase this CL on the master branch in order for the tests to pass
Thanks, the PR should be rebased and ready for the pipeline now.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Tarik C. BrownI believe you'll need to rebase this CL on the master branch in order for the tests to pass
Thanks, the PR should be rebased and ready for the pipeline now.
@mka...@google.com Can you run the CL again?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Commit-Queue | +1 |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Tarik C. BrownI believe you'll need to rebase this CL on the master branch in order for the tests to pass
Tarik C. BrownThanks, the PR should be rebased and ready for the pipeline now.
@mka...@google.com Can you run the CL again?
Ran it again, although I have not had time to review this change yet.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |