Skip to content

Commit

Permalink
Merge branch 'golang:master' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
yimiaoxiehou committed May 30, 2024
2 parents bb71b75 + 1d1fe76 commit 81d43b8
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 26 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ provides rich language support for the
## Requirements

* Visual Studio Code 1.75 or newer (or editors compatible with VS Code 1.75+ APIs)
* Go 1.18 or newer
* Go 1.19 or newer.

## Quick Start

Welcome! 👋🏻<br/>
Whether you are new to Go or an experienced Go developer, we hope this
extension fits your needs and enhances your development experience.

1. Install [Go](https://go.dev) 1.18 or newer if you haven't already.
1. Install [Go](https://go.dev) 1.19 or newer if you haven't already.

1. Install the [VS Code Go extension].

Expand Down
2 changes: 1 addition & 1 deletion extension/src/goEnvironmentStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ async function downloadGo(goOption: GoEnvironmentOption): Promise<GoEnvironmentO
});
if (result) {
outputChannel.error(`Error installing ${goOption.binpath}: ${result}`);
throw new Error('Could not install ${goOption.binpath}');
throw new Error(`Could not install ${goOption.binpath} - check logs in the "Go" output channel`);
}
// run `goX.X download`
const goXExecutable = getBinPath(newExecutableName);
Expand Down
20 changes: 10 additions & 10 deletions extension/src/goInstallTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,12 @@ export async function installTools(
});
}

const minVersion = goForInstall.lt('1.21') ? (goVersion.lt('1.18') ? '1.18' : goVersion.format()) : '1.21';
const minVersion = goForInstall.lt('1.21') ? (goVersion.lt('1.19') ? '1.19' : goVersion.format()) : '1.21.0';
if (goForInstall.lt(minVersion)) {
vscode.window.showErrorMessage(
`Failed to find a go command (go${minVersion} or newer) needed to install tools. ` +
`The go command (${goForInstall.binaryPath}) is too old (go${goForInstall.svString}). ` +
'If your project requires a Go version older than go1.18, either manually install the tools or, use the "go.toolsManagement.go" setting ' +
'If your project requires a Go version older than go1.19, either manually install the tools or, use the "go.toolsManagement.go" setting ' +
'to configure the Go version used for tools installation. See https://github.com/golang/vscode-go/issues/2898.'
);
return missing.map((tool) => {
Expand Down Expand Up @@ -755,7 +755,7 @@ async function defaultInspectGoToolVersion(
dep github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
if the binary was built with a dev version of go, in module mode.
/Users/hakim/go/bin/gopls: devel go1.18-41f485b9a7 Mon Jan 31 13:43:52 2022 +0000
/Users/hakim/go/bin/gopls: devel go1.21-41f485b9a7 Mon Jan 31 13:43:52 2022 +0000
path golang.org/x/tools/gopls
mod golang.org/x/tools/gopls v0.8.0-pre.1 h1:6iHi9bCJ8XndQtBEFFG/DX+eTJrf2lKFv4GI3zLeDOo=
...
Expand Down Expand Up @@ -800,7 +800,7 @@ export async function shouldUpdateTool(tool: Tool, toolPath: string): Promise<bo

export async function suggestUpdates() {
const configuredGoVersion = await getGoVersion();
if (!configuredGoVersion || configuredGoVersion.lt('1.16')) {
if (!configuredGoVersion || configuredGoVersion.lt('1.19')) {
// User is using an ancient or a dev version of go. Don't suggest updates -
// user should know what they are doing.
return;
Expand Down Expand Up @@ -876,12 +876,12 @@ export async function listOutdatedTools(configuredGoVersion: GoVersion | undefin
// We test the inequality by checking whether the exact beta or rc version
// appears in the `go version` output. e.g.,
// configuredGoVersion.version goVersion(tool) update
// 'go version go1.18 ...' 'go1.18beta1' Yes
// 'go version go1.18beta1 ...' 'go1.18beta1' No
// 'go version go1.18beta2 ...' 'go1.18beta1' Yes
// 'go version go1.18rc1 ...' 'go1.18beta1' Yes
// 'go version go1.18rc1 ...' 'go1.18' No
// 'go version devel go1.18-deadbeaf ...' 'go1.18beta1' No (* rare)
// 'go version go1.21 ...' 'go1.21beta1' Yes
// 'go version go1.21beta1 ...' 'go1.21beta1' No
// 'go version go1.21beta2 ...' 'go1.21beta1' Yes
// 'go version go1.21rc1 ...' 'go1.21beta1' Yes
// 'go version go1.21rc1 ...' 'go1.21' No
// 'go version devel go1.21-deadbeaf ...' 'go1.21beta1' No (* rare)
!configuredGoVersion.version.includes(goVersion)
) {
return tool;
Expand Down
13 changes: 10 additions & 3 deletions extension/src/goTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,24 @@ export function getImportPathWithVersion(
return importPath + '@' + version;
}
}
if (tool.name === 'gopls') {
if (goVersion.lt('1.19')) return importPath + '@v0.14.2';
if (goVersion.lt('1.21')) return importPath + '@v0.15.3';
}
if (tool.name === 'dlv') {
if (goVersion.lt('1.19')) return importPath + '@v1.20.2';
if (goVersion.lt('1.21')) return importPath + '@v1.22.1';
}
if (tool.name === 'staticcheck') {
if (goVersion.lt('1.17')) return importPath + '@v0.2.2';
if (goVersion.lt('1.19')) return importPath + '@v0.3.3';
if (goVersion.lt('1.21')) return importPath + '@v0.4.7';
}
if (tool.name === 'gofumpt') {
if (goVersion.lt('1.18')) return importPath + '@v0.2.1';
if (goVersion.lt('1.19')) return importPath + '@v0.4.0';
if (goVersion.lt('1.20')) return importPath + '@v0.5.0';
if (goVersion.lt('1.21')) return importPath + '@v0.6.0';
}
if (tool.name === 'golangci-lint') {
if (goVersion.lt('1.18')) return importPath + '@v1.47.3';
if (goVersion.lt('1.20')) return importPath + '@v1.53.3';
if (goVersion.lt('1.21')) return importPath + '@v1.55.2';
}
Expand Down
10 changes: 5 additions & 5 deletions extension/src/goToolsInformation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ export const allToolsInformation: { [key: string]: Tool } = {
isImportant: true,
description: 'Language Server from Google',
usePrereleaseInPreviewMode: true,
minimumGoVersion: semver.coerce('1.18'),
latestVersion: semver.parse('v0.14.2'),
latestVersionTimestamp: moment('2023-11-14', 'YYYY-MM-DD'),
latestPrereleaseVersion: semver.parse('v0.14.2'),
latestPrereleaseVersionTimestamp: moment('2023-11-14', 'YYYY-MM-DD')
minimumGoVersion: semver.coerce('1.19'),
latestVersion: semver.parse('v0.15.3'),
latestVersionTimestamp: moment('2024-04-12', 'YYYY-MM-DD'),
latestPrereleaseVersion: semver.parse('v0.15.3'),
latestPrereleaseVersionTimestamp: moment('2024-04-12', 'YYYY-MM-DD')
},
'dlv': {
name: 'dlv',
Expand Down
6 changes: 3 additions & 3 deletions extension/tools/allTools.ts.in
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const allToolsInformation: { [key: string]: Tool } = {
replacedByGopls: true,
isImportant: false,
description: 'Formatter',
defaultVersion: 'v0.5.0'
defaultVersion: 'v0.6.0'
},
'goimports': {
name: 'goimports',
Expand Down Expand Up @@ -100,7 +100,7 @@ export const allToolsInformation: { [key: string]: Tool } = {
isImportant: true,
description: 'Language Server from Google',
usePrereleaseInPreviewMode: true,
minimumGoVersion: semver.coerce('1.18'),
minimumGoVersion: semver.coerce('1.19'),
latestVersion: semver.parse('%s'),
latestVersionTimestamp: moment('%s', 'YYYY-MM-DD'),
latestPrereleaseVersion: semver.parse('%s'),
Expand All @@ -122,7 +122,7 @@ export const allToolsInformation: { [key: string]: Tool } = {
importPath: 'github.com/golang/vscode-go/vscgo',
modulePath: 'github.com/golang/vscode-go/vscgo',
replacedByGopls: false,
isImportant: false, // TODO: set to true when we need it
isImportant: false, // TODO: set to true when we need it
description: 'VS Code Go helper program',
minimumGoVersion: semver.coerce('1.18')
}
Expand Down
4 changes: 2 additions & 2 deletions extension/tools/installtools/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ var tools = []struct {
{"golang.org/x/tools/gopls", "", true, nil},
{"github.com/cweill/gotests/gotests", "", false, nil},
{"github.com/haya14busa/goplay/cmd/goplay", "", false, nil},
{"honnef.co/go/tools/cmd/staticcheck", "", false, []finalVersion{{16, "v0.2.2"}, {18, "v0.3.3"}}},
{"github.com/go-delve/delve/cmd/dlv", "", false, []finalVersion{{16, "v1.8.3"}, {17, "v1.9.1"}, {18, "v1.20.2"}}},
{"honnef.co/go/tools/cmd/staticcheck", "", false, []finalVersion{{18, "v0.3.3"}, {20, "v0.4.7"}}},
{"github.com/go-delve/delve/cmd/dlv", "", false, []finalVersion{{16, "v1.8.3"}, {17, "v1.9.1"}, {18, "v1.20.2"}, {20, "v1.22.1"}}},
}

// pickVersion returns the version to install based on the supported
Expand Down

0 comments on commit 81d43b8

Please sign in to comment.