Skip to content

Commit 22e26cc

Browse files
committed
[release] prepare v0.41.3 release
d0d95ab extension/CHANGELOG.md: add a note for v0.41.3 b501de3 Revert "docs: update the debugging doc about remote mode default adapter" 9330b08 extension/src/goTelemetry: do our JSON enc/dec for telemetry start time f8173bc extension/src/welcome: fix 'go.showWelcome' setting interpretation ad37a53 Revert "src/goDebugConfiguration: change remote/attach default to dlv-dap" 40990c0 extension: resolve variables in customFormatter field. 78deb71 docs: fix tools information doc link Change-Id: Ia32f0b7babc681365a02f5fd99b25573fb7934ab
2 parents c7b9dd6 + d0d95ab commit 22e26cc

File tree

14 files changed

+222
-104
lines changed

14 files changed

+222
-104
lines changed

docs/debugging-legacy.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
The Go extension historically used a small adapter program to work with the Go debugger, [Delve].
44
The extension transitioned to communicate with [Delve] directly but there are still cases you may
5-
need to use the legacy debug adapter. This document explains how to use the
5+
need to use the legacy debug adapter (e.g. remote debugging). This document explains how to use the
66
***legacy*** debug adapter.
77

88

@@ -45,6 +45,8 @@ To opt in to use the legacy debug adapter (`legacy`) by default, add the followi
4545
```
4646

4747
If you want to use the legacy mode for only a subset of your launch configurations, you can use [the `debugAdapter` attribute](#launchjson-attributes) to switch between `"dlv-dap"` and `"legacy"` mode.
48+
For [Remote Debugging](#remote-debugging) (launch configuration with `"mode": "remote"` attribute),
49+
the extension will use the `"legacy"` mode by default, so setting this attribute won't be necessary.
4850

4951
Throughout this document, we assume that you opted in to use the legacy debug adapter.
5052
For debugging using the new debug adapter (default, `"dlv-dap"` mode), please see the documentation about [Debugging](https://github.com/golang/vscode-go/tree/master/docs/debugging-legacy.md).

docs/debugging.md

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,26 @@ activities using
66
[VS Code’s Debugging UI](https://code.visualstudio.com/docs/editor/debugging).
77

88
These debugging features are possible by using
9-
[Delve](https://github.com/go-delve/delve), the Go debugger, and its
10-
[native debug adapter implementation](https://github.com/go-delve/delve/tree/master/service/dap).
9+
[Delve](https://github.com/go-delve/delve), the Go debugger.
10+
11+
Previously, the Go extension communicated with Delve through a custom debug
12+
adaptor program (`legacy` mode). Since
13+
[`Delve`'s native debug adapter implementation](https://github.com/go-delve/delve/tree/master/service/dap)
14+
is available, the Go extension is transitioning to deprecate the legacy debug
15+
adapter in favor of direct communication with Delve via
16+
[DAP](https://microsoft.github.io/debug-adapter-protocol/overview).
17+
18+
19+
📣 **We are happy to announce that the new _`dlv-dap`_ mode of Delve
20+
integration is enabled for _local_ _debugging_ by default. For
21+
[_remote_ _debugging_](#remote-debugging) it is the default in
22+
[Go Nightly](nightly.md) and is available with stable builds on demand with
23+
`"debugAdapter": "dlv-dap"` attribute in `launch.json` or `settings.json`!**
24+
25+
Many features and settings described in this document may be available only with
26+
the new `dlv-dap` mode. For troubleshooting and configuring the legacy debug
27+
adapter, see
28+
[the legacy debug adapter documentation](https://github.com/golang/vscode-go/tree/master/docs/debugging-legacy.md).
1129

1230
## Get started
1331

@@ -64,9 +82,7 @@ from the tree head.
6482

6583
### Switch to legacy debug adapter
6684

67-
Previously, the Go extension communicated with Delve through a custom debug
68-
adaptor program (aka `legacy` mode). This legacy adapter is no longer maintained
69-
and will be removed by the end of 2024 H2.
85+
Note: The extension still uses the legacy debug adapter for remote debugging.
7086

7187
If you need to use the legacy debug adapter for local debugging (`legacy` mode)
7288
by default, add the following in your VSCode settings.
@@ -77,6 +93,9 @@ by default, add the following in your VSCode settings.
7793
}
7894
```
7995

96+
When `mode` is set to `remote` you must explicitly set `debugAdapter` to
97+
`dlv-dap` to override the legacy adapter default.
98+
8099
If you want to switch to `legacy` for only a subset of your launch
81100
configurations, you can use
82101
[the `debugAdapter` attribute](#launchjson-attributes) to switch between
@@ -790,8 +809,8 @@ with a running target.
790809

791810
The
792811
[headless dlv server](https://github.com/go-delve/delve/tree/master/Documentation/api)
793-
can now be used with both `"debugAdapter": "dlv-dap"` (default) and
794-
`"debugAdapter": "legacy"` (with Delve v1.7.3 or newer) as well as Delve's
812+
can now be used with both `"debugAdapter": "legacy"` (default value) and
813+
`"debugAdapter": "dlv-dap"` (with Delve v1.7.3 or newer) as well as Delve's
795814
[command-line interface](https://github.com/go-delve/delve/tree/master/Documentation/cli)
796815
via `dlv connect`. The `--accept-multiclient` flag makes this a multi-use server
797816
that persists on `Disconnect` from a client and allows repeated connections from
@@ -818,6 +837,7 @@ Connect to it with a remote attach configuration in your `launch.json`:
818837
{
819838
"name": "Connect to external session",
820839
"type": "go",
840+
"debugAdapter": "dlv-dap", // `legacy` by default
821841
"request": "attach",
822842
"mode": "remote",
823843
"port": 12345,

docs/tools.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This document describes the tools that power the VS Code Go extension.
44

5-
Tools will be installed by default when you install the extension. You can also manually install or update all of these tools by running the [`Go: Install/Update Tools`](commands.md#go-installupdate-tools) command. The extension uses pinned versions of command-line tools. See the pinned versions in tools information [here](https://github.com/golang/vscode-go/blob/master/src/goToolsInformation.ts). If any tools are missing, you will see an `Analysis Tools Missing` warning in the bottom-right corner of the editor, which will prompt you to install these tools.
5+
Tools will be installed by default when you install the extension. You can also manually install or update all of these tools by running the [`Go: Install/Update Tools`](commands.md#go-installupdate-tools) command. The extension uses pinned versions of command-line tools. See the pinned versions in tools information [here](https://github.com/golang/vscode-go/blob/master/extension/src/goToolsInformation.ts). If any tools are missing, you will see an `Analysis Tools Missing` warning in the bottom-right corner of the editor, which will prompt you to install these tools.
66

77
VS Code Go will install the tools to your `$GOPATH/bin` by default.
88

extension/CHANGELOG.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,41 @@
1+
## v0.41.3 - 22 Apr, 2024
2+
3+
This point release temporarily reverts the default remote debugging behavior to
4+
use the legacy debug adapter due to existing feature gaps.
5+
Once these gaps are addressed as outlined in
6+
[Issue 3096](https://github.com/golang/vscode-go/issues/3096),
7+
we plan to switch the default back to use Delve DAP for remote deubgging.
8+
9+
If you want to continue using [Delve DAP for remote debugging](https://github.com/golang/vscode-go/wiki/debugging#connect-to-headless-delve-with-target-specified-at-server-start-up), use the following
10+
settings in your `launch.json`.
11+
12+
```json
13+
{
14+
"name": "Debug Remote",
15+
"type": "go",
16+
"request": "attach",
17+
"mode": "remote",
18+
"debugAdapter": "dlv-dap", // Use Delve DAP
19+
...
20+
}
21+
```
22+
23+
See the full
24+
[commit history](https://github.com/golang/vscode-go/compare/v0.41.2...v0.41.3)
25+
for detailed changes.
26+
27+
### Fixes
28+
- Fixed to substitute variables used in `go.alternateTools` setting's
29+
`customFormatter` entry ([Issue 2582](https://github.com/golang/vscode-go/issues/2582)).
30+
- Corrected handling of `go.showWelcome` setting
31+
([Issue 3319](https://github.com/golang/vscode-go/issues/3319)).
32+
- Addressed Go telemetry prompt issue in the latest Visual Studio Code
33+
([Issue 3312](https://github.com/golang/vscode-go/issues/3312)).
34+
35+
### Thanks
36+
37+
Thanks for your contributions, @uniquefine, @monitor1379, @suzmue, @hyangah!
38+
139
## v0.41.2 - 14 Mar, 2024
240

341
This release is a point release to increase the prompt rate of Go telemetry

extension/src/goDebugConfiguration.ts

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -183,36 +183,25 @@ export class GoDebugConfigurationProvider implements vscode.DebugConfigurationPr
183183
}
184184
}
185185
// If neither launch.json nor settings.json gave us the debugAdapter value, we go with the default
186-
// from package.json (dlv-dap).
186+
// from package.json (dlv-dap) unless this is remote attach with a stable release.
187187
if (!debugConfiguration['debugAdapter']) {
188188
debugConfiguration['debugAdapter'] = defaultConfig.debugAdapter.default;
189-
if (
190-
debugConfiguration.request === 'attach' &&
191-
debugConfiguration['mode'] === 'remote' &&
192-
!extensionInfo.isPreview
193-
) {
189+
if (debugConfiguration['mode'] === 'remote' && !extensionInfo.isPreview) {
190+
debugConfiguration['debugAdapter'] = 'legacy';
191+
}
192+
}
193+
if (debugConfiguration['debugAdapter'] === 'dlv-dap') {
194+
if (debugConfiguration['mode'] === 'remote') {
195+
// This needs to use dlv at version 'v1.7.3-0.20211026171155-b48ceec161d5' or later,
196+
// but we have no way of detectng that with an external server ahead of time.
197+
// If an earlier version is used, the attach will fail with warning about versions.
198+
} else if (debugConfiguration['port']) {
194199
this.showWarning(
195-
'ignoreDefaultDebugAdapterChangeWarning',
196-
"We are using the 'dlv-dap' integration for remote debugging by default. Please comment on [issue 3096](https://github.com/golang/vscode-go/issues/3096) if this impacts your workflows."
200+
'ignorePortUsedInDlvDapWarning',
201+
"`port` with 'dlv-dap' debugAdapter connects to [an external `dlv dap` server](https://github.com/golang/vscode-go/blob/master/docs/debugging.md#running-debugee-externally) to launch a program or attach to a process. Remove 'host' and 'port' from your launch.json if you have not launched a 'dlv dap' server."
197202
);
198203
}
199204
}
200-
if (debugConfiguration['debugAdapter'] === 'legacy') {
201-
this.showWarning(
202-
'ignoreLegacyDADeprecationWarning',
203-
'Legacy debug adapter is deprecated. Please comment on [issue 3096](https://github.com/golang/vscode-go/issues/3096) if this impacts your workflows.'
204-
);
205-
}
206-
if (
207-
debugConfiguration['debugAdapter'] === 'dlv-dap' &&
208-
debugConfiguration.request === 'launch' &&
209-
debugConfiguration['port']
210-
) {
211-
this.showWarning(
212-
'ignorePortUsedInDlvDapWarning',
213-
"`port` with 'dlv-dap' debugAdapter connects to [a `dlv dap` server](https://github.com/golang/vscode-go/wiki/debugging#run-debugee-externally) to launch a program or attach to a process. Remove 'host'/'port' from your launch.json configuration if you have not launched a 'dlv dap' server."
214-
);
215-
}
216205

217206
const debugAdapter = debugConfiguration['debugAdapter'] === 'dlv-dap' ? 'dlv-dap' : 'dlv';
218207

extension/src/goMain.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,24 @@ import { telemetryReporter } from './goTelemetry';
7676

7777
const goCtx: GoExtensionContext = {};
7878

79-
export async function activate(ctx: vscode.ExtensionContext): Promise<ExtensionAPI | undefined> {
79+
// Allow tests to access the extension context utilities.
80+
interface ExtensionTestAPI {
81+
globalState: vscode.Memento;
82+
}
83+
84+
export async function activate(ctx: vscode.ExtensionContext): Promise<ExtensionAPI | ExtensionTestAPI | undefined> {
8085
if (process.env['VSCODE_GO_IN_TEST'] === '1') {
81-
// Make sure this does not run when running in test.
82-
return;
86+
// TODO: VSCODE_GO_IN_TEST was introduced long before we learned about
87+
// ctx.extensionMode, and used in multiple places.
88+
// Investigate if use of VSCODE_GO_IN_TEST can be removed
89+
// in favor of ctx.extensionMode and clean up.
90+
if (ctx.extensionMode === vscode.ExtensionMode.Test) {
91+
return { globalState: ctx.globalState };
92+
}
93+
// We shouldn't expose the memento in production mode even when VSCODE_GO_IN_TEST
94+
// environment variable is set.
95+
return; // Skip the remaining activation work.
8396
}
84-
8597
const start = Date.now();
8698
setGlobalState(ctx.globalState);
8799
setWorkspaceState(ctx.workspaceState);

extension/src/goTelemetry.ts

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,25 @@ export const GOPLS_MAYBE_PROMPT_FOR_TELEMETRY = 'gopls.maybe_prompt_for_telemetr
2121
// Exported for testing.
2222
export const TELEMETRY_START_TIME_KEY = 'telemetryStartTime';
2323

24+
// Run our encode/decode function for the Date object, to be defensive
25+
// from vscode Memento API behavior change.
26+
// Exported for testing.
27+
export function recordTelemetryStartTime(storage: vscode.Memento, date: Date) {
28+
storage.update(TELEMETRY_START_TIME_KEY, date.toJSON());
29+
}
30+
31+
function readTelemetryStartTime(storage: vscode.Memento): Date | null {
32+
const value = storage.get<string | number | Date>(TELEMETRY_START_TIME_KEY);
33+
if (!value) {
34+
return null;
35+
}
36+
const telemetryStartTime = new Date(value);
37+
if (telemetryStartTime.toString() === 'Invalid Date') {
38+
return null;
39+
}
40+
return telemetryStartTime;
41+
}
42+
2443
enum ReporterState {
2544
NOT_INITIALIZED,
2645
IDLE,
@@ -153,9 +172,9 @@ export class TelemetryService {
153172
this.active = true;
154173
// record the first time we see the gopls with telemetry support.
155174
// The timestamp will be used to avoid prompting too early.
156-
const telemetryStartTime = globalState.get<Date>(TELEMETRY_START_TIME_KEY);
175+
const telemetryStartTime = readTelemetryStartTime(globalState);
157176
if (!telemetryStartTime) {
158-
globalState.update(TELEMETRY_START_TIME_KEY, new Date());
177+
recordTelemetryStartTime(globalState, new Date());
159178
}
160179
}
161180

@@ -172,9 +191,11 @@ export class TelemetryService {
172191
if (!isVSCodeTelemetryEnabled) return;
173192

174193
// Allow at least 7days for gopls to collect some data.
175-
const now = new Date();
176-
const telemetryStartTime = this.globalState.get<Date>(TELEMETRY_START_TIME_KEY, now);
177-
if (daysBetween(telemetryStartTime, now) < 7) {
194+
const telemetryStartTime = readTelemetryStartTime(this.globalState);
195+
if (!telemetryStartTime) {
196+
return;
197+
}
198+
if (daysBetween(telemetryStartTime, new Date()) < 7) {
178199
return;
179200
}
180201

extension/src/language/legacy/goFormat.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import vscode = require('vscode');
1212
import { getGoConfig } from '../../config';
1313
import { toolExecutionEnvironment } from '../../goEnv';
1414
import { promptForMissingTool, promptForUpdatingTool } from '../../goInstallTools';
15-
import { getBinPath } from '../../util';
15+
import { getBinPath, resolvePath } from '../../util';
1616
import { killProcessTree } from '../../utils/processUtils';
1717

1818
export class GoDocumentFormattingEditProvider implements vscode.DocumentFormattingEditProvider {
@@ -144,7 +144,7 @@ export function getFormatTool(goConfig: { [key: string]: any }): string {
144144
return 'goimports';
145145
}
146146
if (formatTool === 'custom') {
147-
return goConfig['alternateTools']['customFormatter'] || 'goimports';
147+
return resolvePath(goConfig['alternateTools']['customFormatter'] || 'goimports');
148148
}
149149
return formatTool;
150150
}

extension/src/welcome.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import path = require('path');
1212
import semver = require('semver');
1313
import { extensionId } from './const';
1414
import { GoExtensionContext } from './context';
15-
import { extensionInfo } from './config';
15+
import { extensionInfo, getGoConfig } from './config';
1616
import { getFromGlobalState, updateGlobalState } from './stateUtils';
1717
import { createRegisterCommand } from './commands';
1818

@@ -29,11 +29,7 @@ export class WelcomePanel {
2929
}
3030
});
3131
}
32-
33-
// Show the Go welcome page on update.
34-
if (!extensionInfo.isInCloudIDE && vscode.workspace.getConfiguration('go.showWelcome')) {
35-
showGoWelcomePage();
36-
}
32+
showGoWelcomePage();
3733
}
3834

3935
public static currentPanel: WelcomePanel | undefined;
@@ -278,6 +274,9 @@ function showGoWelcomePage() {
278274
}
279275

280276
export function shouldShowGoWelcomePage(showVersions: string[], newVersion: string, oldVersion: string): boolean {
277+
if (!extensionInfo.isInCloudIDE && getGoConfig().get('showWelcome') === false) {
278+
return false;
279+
}
281280
if (newVersion === oldVersion) {
282281
return false;
283282
}

extension/test/gopls/extension.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import * as vscode from 'vscode';
1010
import { getGoConfig } from '../../src/config';
1111
import sinon = require('sinon');
1212
import { getGoVersion, GoVersion } from '../../src/util';
13-
import { GOPLS_MAYBE_PROMPT_FOR_TELEMETRY, TELEMETRY_START_TIME_KEY, TelemetryService } from '../../src/goTelemetry';
13+
import { GOPLS_MAYBE_PROMPT_FOR_TELEMETRY, recordTelemetryStartTime, TelemetryService } from '../../src/goTelemetry';
1414
import { MockMemento } from '../mocks/MockMemento';
1515
import { Env } from './goplsTestEnv.utils';
1616

@@ -205,8 +205,7 @@ suite('Go Extension Tests With Gopls', function () {
205205
const workspaceDir = path.resolve(testdataDir, 'gogetdocTestData');
206206
await env.startGopls(path.join(workspaceDir, 'test.go'), undefined, workspaceDir);
207207
const memento = new MockMemento();
208-
memento.update(TELEMETRY_START_TIME_KEY, new Date('2000-01-01'));
209-
208+
recordTelemetryStartTime(memento, new Date('2000-01-01'));
210209
const sut = new TelemetryService(env.languageClient, memento, [GOPLS_MAYBE_PROMPT_FOR_TELEMETRY]);
211210
try {
212211
await Promise.all([

0 commit comments

Comments
 (0)