Skip to content

Commit b81dc3d

Browse files
logica0419h9jiang
authored andcommitted
extension/src/goLint: adding .exe extension to the binary name on Windows
This change ensures that the tools with major versions higher than v2 can be properly installed on Windows systems. An error occurred in the binary copying process due to the missing .exe extension. Fixes #3777 Change-Id: Iecd1d419bf87be622986ac1d023274e9914992c5 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/683195 Reviewed-by: Madeline Kalil <[email protected]> Reviewed-by: Hongxiang Jiang <[email protected]> kokoro-CI: kokoro <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent ea77a56 commit b81dc3d

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

extension/src/goInstallTools.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,10 @@ export async function installTools(
255255
// v2, v3... of the tools are installed with the same name as v1,
256256
// but must be able to co-exist with other major versions in the GOBIN.
257257
// Thus, we install it in a tmp directory and copy it to the GOBIN.
258-
// See detail: golang/vscode-go#3732
259-
if (tool.name.match('-v\\d+$')) {
258+
// See detail: https://github.com/golang/vscode-go/issues/3732#issuecomment-2752026894
259+
const isUpgradedMajorVersion = tool.name.match('-v\\d+$');
260+
261+
if (isUpgradedMajorVersion) {
260262
envForTools['GOBIN'] = path.join(installingPath, 'tmp');
261263
}
262264

@@ -268,15 +270,18 @@ export async function installTools(
268270
vscode.commands.executeCommand('go.languageserver.restart', RestartReason.INSTALLATION);
269271
}
270272

271-
if (tool.name.match('-v\\d+$')) {
273+
if (isUpgradedMajorVersion) {
272274
// grep the tool name without version.
273275
const toolName = tool.name.match('^(?<tool>.+)-v\\d+$')?.groups?.tool;
274276
if (!toolName) {
275277
failures.push({ tool, reason: 'failed to grep tool name with regex' });
276278
continue;
277279
}
278280

279-
fs.copyFileSync(path.join(installingPath, 'tmp', toolName), path.join(installingPath, tool.name));
281+
fs.copyFileSync(
282+
path.join(installingPath, 'tmp', correctBinname(toolName)),
283+
path.join(installingPath, correctBinname(tool.name))
284+
);
280285
fs.rmdirSync(path.join(installingPath, 'tmp'), { recursive: true });
281286
}
282287
}

0 commit comments

Comments
 (0)