Skip to content

Commit 5bbfaf9

Browse files
committed
[release] prepare v0.41.2 release
f5d6cad extension/src/goStatus: fix quick pick for gopls trace open 53bf019 src/language: adjust panic trace capture logic b4b68a7 README.md: use the new telemetry official doc link 361c801 extension/src/goTelemetry: increase telemetry prompt rate to 1% 0b3fabc extension/src/goMain: skip vscgo installation on windows 9480a16 extension: start v0.42.0 dev cycle beaf5fc extension/test/gopls: allow more time for testify tests 484a195 extension/src/goTools: add golangci-lint and gofumpt version mapping 1d634bf .github/workflows: use 1.22, drop 1.18 6dd3745 docs/tools.md: fix vscgo package doc link baab7be extension/tools/release: add test for rc 7bfbcaf src/goTest: fix multifile suite test fails to debug Change-Id: I966aaac48ecb67b22824bd7b3600bf90d983a039
2 parents 2ba3f68 + f5d6cad commit 5bbfaf9

29 files changed

+459
-103
lines changed

.github/workflows/test-long-all.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
matrix:
1818
os: [ubuntu-latest, windows-latest, macos-latest]
1919
version: ['stable', 'insiders']
20-
go: ['1.18', '1.19', '1.20', '1.21']
20+
go: ['1.19', '1.20', '1.21', '1.22']
2121

2222
steps:
2323
- name: Clone repository

.github/workflows/test-long.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
matrix:
1717
os: [ubuntu-latest, windows-latest] # TODO: reenable macos-latest
1818
version: ['stable']
19-
go: ['1.18', '1.19', '1.20', '1.21']
19+
go: ['1.19', '1.20', '1.21', '1.22']
2020

2121
steps:
2222
- name: Clone repository

.github/workflows/test-smoke.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- name: Setup Go
3232
uses: actions/setup-go@v4
3333
with:
34-
go-version: '1.21'
34+
go-version: '1.22'
3535
check-latest: true
3636
cache: true
3737

.github/workflows/wiki.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
- name: Setup Go
3636
uses: actions/setup-go@v4
3737
with:
38-
go-version: '1.21'
38+
go-version: '1.22'
3939
check-latest: true
4040
cache: true
4141
cache-dependency-path: '**/go.sum'

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ nightly build of this extension. Learn how to install it in by reading the
133133

134134
## Telemetry
135135

136-
VS Code Go extension relies on the [Go Telemetry](https://telemetry.go.dev) to
136+
VS Code Go extension relies on the [Go Telemetry](https://go.dev/doc/telemetry) to
137137
learn insights about the performance and stability of the extension and the
138138
language server (`gopls`).
139139
**Go Telemetry data uploading is disabled by default** and can be enabled
@@ -171,9 +171,8 @@ of reliability. For example:
171171
These are just a few ways that telemetry can improve gopls. The [telemetry blog
172172
post series](https://research.swtch.com/telemetry-uses) contains many more.
173173

174-
Go telemetry is designed to be transparent and privacy-preserving. If you have
175-
concerns about enabling telemetry, you can learn more at
176-
[https://telemetry.go.dev/privacy](https://telemetry.go.dev/privacy).
174+
Go telemetry is designed to be transparent and privacy-preserving. Learn more at
175+
[https://go.dev/doc/telemetry](https://go.dev/doc/telemetry).
177176

178177
## Contributing
179178

extension/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## v0.41.2 - 14 Mar, 2024
2+
3+
This release is a point release to increase the prompt rate of Go telemetry
4+
opt-in. Learn more at https://go.dev/doc/telemetry.
5+
For a detailed list of changes, refer to the complete
6+
[commit history](https://github.com/golang/vscode-go/compare/v0.41.1...v0.41.2).
7+
18
## v0.41.1 - 22 Feb, 2024
29

310
This release is a point release to skip `vscgo` installation on Windows

extension/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extension/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "go",
33
"displayName": "Go",
4-
"version": "0.41.1",
4+
"version": "0.41.2",
55
"publisher": "golang",
66
"description": "Rich Go language support for Visual Studio Code",
77
"author": {

extension/src/goStatus.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export const expandGoStatusBar: CommandFactory = (ctx, goCtx) => async () => {
106106
case 'Choose Go Environment':
107107
vscode.commands.executeCommand('go.environment.choose');
108108
break;
109-
case `${languageServerIcon}Open 'gopls' trace`:
109+
case `${languageServerIcon} Open 'gopls' trace`:
110110
if (serverOutputChannel) {
111111
serverOutputChannel.show();
112112
}

extension/src/goTelemetry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export class TelemetryService {
162162
async promptForTelemetry(
163163
isPreviewExtension: boolean,
164164
isVSCodeTelemetryEnabled: boolean = vscode.env.isTelemetryEnabled,
165-
samplingInterval = 1 /* prompt N out of 1000. 1 = 0.1% */
165+
samplingInterval = 10 /* prompt N out of 1000. 10 = 1% */
166166
) {
167167
if (!this.active) return;
168168

extension/src/goTest.ts

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ import {
1818
getBenchmarkFunctions,
1919
getTestFlags,
2020
getTestFunctionDebugArgs,
21-
getTestFunctions,
21+
getTestFunctionsAndTestSuite,
2222
getTestTags,
2323
goTest,
24-
TestConfig
24+
TestConfig,
25+
SuiteToTestMap,
26+
getTestFunctions
2527
} from './testUtils';
2628

2729
// lastTestConfig holds a reference to the last executed TestConfig which allows
@@ -52,8 +54,11 @@ async function _testAtCursor(
5254
throw new NotFoundError('No tests found. Current file is not a test file.');
5355
}
5456

55-
const getFunctions = cmd === 'benchmark' ? getBenchmarkFunctions : getTestFunctions;
56-
const testFunctions = (await getFunctions(goCtx, editor.document)) ?? [];
57+
const { testFunctions, suiteToTest } = await getTestFunctionsAndTestSuite(
58+
cmd === 'benchmark',
59+
goCtx,
60+
editor.document
61+
);
5762
// We use functionName if it was provided as argument
5863
// Otherwise find any test function containing the cursor.
5964
const testFunctionName =
@@ -67,9 +72,9 @@ async function _testAtCursor(
6772
await editor.document.save();
6873

6974
if (cmd === 'debug') {
70-
return debugTestAtCursor(editor, testFunctionName, testFunctions, goConfig);
75+
return debugTestAtCursor(editor, testFunctionName, testFunctions, suiteToTest, goConfig);
7176
} else if (cmd === 'benchmark' || cmd === 'test') {
72-
return runTestAtCursor(editor, testFunctionName, testFunctions, goConfig, cmd, args);
77+
return runTestAtCursor(editor, testFunctionName, testFunctions, suiteToTest, goConfig, cmd, args);
7378
} else {
7479
throw new Error(`Unsupported command: ${cmd}`);
7580
}
@@ -92,7 +97,7 @@ async function _subTestAtCursor(
9297
}
9398

9499
await editor.document.save();
95-
const testFunctions = (await getTestFunctions(goCtx, editor.document)) ?? [];
100+
const { testFunctions, suiteToTest } = await getTestFunctionsAndTestSuite(false, goCtx, editor.document);
96101
// We use functionName if it was provided as argument
97102
// Otherwise find any test function containing the cursor.
98103
const currentTestFunctions = testFunctions.filter((func) => func.range.contains(editor.selection.start));
@@ -142,9 +147,9 @@ async function _subTestAtCursor(
142147
const escapedName = escapeSubTestName(testFunctionName, subTestName);
143148

144149
if (cmd === 'debug') {
145-
return debugTestAtCursor(editor, escapedName, testFunctions, goConfig);
150+
return debugTestAtCursor(editor, escapedName, testFunctions, suiteToTest, goConfig);
146151
} else if (cmd === 'test') {
147-
return runTestAtCursor(editor, escapedName, testFunctions, goConfig, cmd, args);
152+
return runTestAtCursor(editor, escapedName, testFunctions, suiteToTest, goConfig, cmd, args);
148153
} else {
149154
throw new Error(`Unsupported command: ${cmd}`);
150155
}
@@ -160,7 +165,7 @@ async function _subTestAtCursor(
160165
export function testAtCursor(cmd: TestAtCursorCmd): CommandFactory {
161166
return (ctx, goCtx) => (args: any) => {
162167
const goConfig = getGoConfig();
163-
_testAtCursor(goCtx, goConfig, cmd, args).catch((err) => {
168+
return _testAtCursor(goCtx, goConfig, cmd, args).catch((err) => {
164169
if (err instanceof NotFoundError) {
165170
vscode.window.showInformationMessage(err.message);
166171
} else {
@@ -202,13 +207,14 @@ async function runTestAtCursor(
202207
editor: vscode.TextEditor,
203208
testFunctionName: string,
204209
testFunctions: vscode.DocumentSymbol[],
210+
suiteToTest: SuiteToTestMap,
205211
goConfig: vscode.WorkspaceConfiguration,
206212
cmd: TestAtCursorCmd,
207213
args: any
208214
) {
209215
const testConfigFns = [testFunctionName];
210216
if (cmd !== 'benchmark' && extractInstanceTestName(testFunctionName)) {
211-
testConfigFns.push(...findAllTestSuiteRuns(editor.document, testFunctions).map((t) => t.name));
217+
testConfigFns.push(...findAllTestSuiteRuns(editor.document, testFunctions, suiteToTest).map((t) => t.name));
212218
}
213219

214220
const isMod = await isModSupported(editor.document.uri);
@@ -259,11 +265,12 @@ export async function debugTestAtCursor(
259265
editorOrDocument: vscode.TextEditor | vscode.TextDocument,
260266
testFunctionName: string,
261267
testFunctions: vscode.DocumentSymbol[],
268+
suiteToFunc: SuiteToTestMap,
262269
goConfig: vscode.WorkspaceConfiguration,
263270
sessionID?: string
264271
) {
265272
const doc = 'document' in editorOrDocument ? editorOrDocument.document : editorOrDocument;
266-
const args = getTestFunctionDebugArgs(doc, testFunctionName, testFunctions);
273+
const args = getTestFunctionDebugArgs(doc, testFunctionName, testFunctions, suiteToFunc);
267274
const tags = getTestTags(goConfig);
268275
const buildFlags = tags ? ['-tags', tags] : [];
269276
const flagsFromConfig = getTestFlags(goConfig);

extension/src/goTest/run.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import vscode = require('vscode');
2121
import { outputChannel } from '../goStatus';
2222
import { isModSupported } from '../goModules';
2323
import { getGoConfig } from '../config';
24-
import { getBenchmarkFunctions, getTestFlags, getTestFunctions, goTest, GoTestOutput } from '../testUtils';
24+
import { getTestFlags, getTestFunctionsAndTestSuite, goTest, GoTestOutput } from '../testUtils';
2525
import { GoTestResolver } from './resolve';
2626
import { dispose, forEachAsync, GoTest, Workspace } from './utils';
2727
import { GoTestProfiler, ProfilingOptions } from './profile';
@@ -161,8 +161,11 @@ export class GoTestRunner {
161161
await doc.save();
162162

163163
const goConfig = getGoConfig(test.uri);
164-
const getFunctions = kind === 'benchmark' ? getBenchmarkFunctions : getTestFunctions;
165-
const testFunctions = await getFunctions(this.goCtx, doc, token);
164+
const { testFunctions, suiteToTest } = await getTestFunctionsAndTestSuite(
165+
kind === 'benchmark',
166+
this.goCtx,
167+
doc
168+
);
166169

167170
// TODO Can we get output from the debug session, in order to check for
168171
// run/pass/fail events?
@@ -191,7 +194,8 @@ export class GoTestRunner {
191194

192195
const run = this.ctrl.createTestRun(request, `Debug ${name}`);
193196
if (!testFunctions) return;
194-
const started = await debugTestAtCursor(doc, escapeSubTestName(name), testFunctions, goConfig, id);
197+
const started = await debugTestAtCursor(doc, escapeSubTestName(name), testFunctions, suiteToTest, goConfig, id);
198+
195199
if (!started) {
196200
subs.forEach((s) => s.dispose());
197201
run.end();

extension/src/goTools.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,13 @@ export function getImportPathWithVersion(
7575
}
7676
if (tool.name === 'gofumpt') {
7777
if (goVersion.lt('1.18')) return importPath + '@v0.2.1';
78+
if (goVersion.lt('1.19')) return importPath + '@v0.4.0';
79+
if (goVersion.lt('1.20')) return importPath + '@v0.5.0';
7880
}
7981
if (tool.name === 'golangci-lint') {
8082
if (goVersion.lt('1.18')) return importPath + '@v1.47.3';
8183
if (goVersion.lt('1.20')) return importPath + '@v1.53.3';
84+
if (goVersion.lt('1.21')) return importPath + '@v1.55.2';
8285
}
8386
if (tool.defaultVersion) {
8487
return importPath + '@' + tool.defaultVersion;

extension/src/goToolsInformation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const allToolsInformation: { [key: string]: Tool } = {
3939
replacedByGopls: true,
4040
isImportant: false,
4141
description: 'Formatter',
42-
defaultVersion: 'v0.5.0'
42+
defaultVersion: 'v0.6.0'
4343
},
4444
'goimports': {
4545
name: 'goimports',

extension/src/language/goLanguageServer.ts

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,7 +1530,6 @@ async function collectGoplsLog(goCtx: GoExtensionContext): Promise<{ sanitizedLo
15301530
enum GoplsFailureModes {
15311531
NO_GOPLS_LOG = 'no gopls log',
15321532
EMPTY_PANIC_TRACE = 'empty panic trace',
1533-
INCOMPLETE_PANIC_TRACE = 'incomplete panic trace',
15341533
INCORRECT_COMMAND_USAGE = 'incorrect gopls command usage',
15351534
UNRECOGNIZED_CRASH_PATTERN = 'unrecognized crash pattern'
15361535
}
@@ -1544,34 +1543,40 @@ export function sanitizeGoplsTrace(logs?: string): { sanitizedLog?: string; fail
15441543
const panicMsgBegin = logs.lastIndexOf('panic: ');
15451544
if (panicMsgBegin > -1) {
15461545
// panic message was found.
1547-
const panicMsgEnd = logs.indexOf('Connection to server got closed.', panicMsgBegin);
1546+
let panicTrace = logs.substr(panicMsgBegin);
1547+
const panicMsgEnd = panicTrace.search(/\[(Info|Warning|Error)\s+-\s+/);
15481548
if (panicMsgEnd > -1) {
1549-
const panicTrace = logs.substr(panicMsgBegin, panicMsgEnd - panicMsgBegin);
1550-
const filePattern = /(\S+\.go):\d+/;
1551-
const sanitized = panicTrace
1552-
.split('\n')
1553-
.map((line: string) => {
1554-
// Even though this is a crash from gopls, the file path
1555-
// can contain user names and user's filesystem directory structure.
1556-
// We can still locate the corresponding file if the file base is
1557-
// available because the full package path is part of the function
1558-
// name. So, leave only the file base.
1559-
const m = line.match(filePattern);
1560-
if (!m) {
1561-
return line;
1562-
}
1563-
const filePath = m[1];
1564-
const fileBase = path.basename(filePath);
1565-
return line.replace(filePath, ' ' + fileBase);
1566-
})
1567-
.join('\n');
1568-
1569-
if (sanitized) {
1570-
return { sanitizedLog: sanitized };
1571-
}
1572-
return { failureReason: GoplsFailureModes.EMPTY_PANIC_TRACE };
1549+
panicTrace = panicTrace.substr(0, panicMsgEnd);
1550+
}
1551+
const filePattern = /(\S+\.go):\d+/;
1552+
const sanitized = panicTrace
1553+
.split('\n')
1554+
.map((line: string) => {
1555+
// Even though this is a crash from gopls, the file path
1556+
// can contain user names and user's filesystem directory structure.
1557+
// We can still locate the corresponding file if the file base is
1558+
// available because the full package path is part of the function
1559+
// name. So, leave only the file base.
1560+
const m = line.match(filePattern);
1561+
if (!m) {
1562+
return line;
1563+
}
1564+
const filePath = m[1];
1565+
const fileBase = path.basename(filePath);
1566+
return line.replace(filePath, ' ' + fileBase);
1567+
})
1568+
.join('\n');
1569+
1570+
if (sanitized) {
1571+
return { sanitizedLog: sanitized };
15731572
}
1574-
return { failureReason: GoplsFailureModes.INCOMPLETE_PANIC_TRACE };
1573+
return { failureReason: GoplsFailureModes.EMPTY_PANIC_TRACE };
1574+
}
1575+
// Capture Fatal
1576+
// foo.go:1: the last message (caveat - we capture only the first log line)
1577+
const m = logs.match(/(^\S+\.go:\d+:.*$)/gm);
1578+
if (m && m.length > 0) {
1579+
return { sanitizedLog: m[0].toString() };
15751580
}
15761581
const initFailMsgBegin = logs.lastIndexOf('gopls client:');
15771582
if (initFailMsgBegin > -1) {
@@ -1590,13 +1595,6 @@ export function sanitizeGoplsTrace(logs?: string): { sanitizedLog?: string; fail
15901595
if (logs.lastIndexOf('Usage:') > -1) {
15911596
return { failureReason: GoplsFailureModes.INCORRECT_COMMAND_USAGE };
15921597
}
1593-
// Capture Fatal
1594-
// foo.go:1: the last message (caveat - we capture only the first log line)
1595-
const m = logs.match(/(^\S+\.go:\d+:.*$)/gm);
1596-
if (m && m.length > 0) {
1597-
return { sanitizedLog: m[0].toString() };
1598-
}
1599-
16001598
return { failureReason: GoplsFailureModes.UNRECOGNIZED_CRASH_PATTERN };
16011599
}
16021600

@@ -1664,6 +1662,6 @@ async function getGoplsStats(binpath?: string) {
16641662
} catch (e) {
16651663
const duration = new Date().getTime() - start.getTime();
16661664
console.log(`gopls stats -anon failed: ${JSON.stringify(e)}`);
1667-
return `gopls stats -anon failed after running for ${duration}ms`; // e may contain user information. don't include in the report.
1665+
return `gopls stats -anon failed after ${duration} ms. Please check if gopls is killed by OS.`;
16681666
}
16691667
}

0 commit comments

Comments
 (0)