Skip to content

Commit 1d1fe76

Browse files
committed
extension/src: require go1.19+ for tools installation
Gopls v0.15.x requires go 1.19 or newer. Update the README and the installation error message to clarify the extension requires go 1.19+. Gopls v0.16+ will require go 1.21+. The next staticcheck will require go 1.22+. If go1.21 is used, `go install` will be able to pick up go 1.22, so effectively, the extension does not have to worry about tool's go version requirement any more if the go version used for tools installation is go 1.21+. Encode these version mapping metrix in goTools.ts and installtools script. Run go run tools/generate.go -tools that updates gopls latest version. Fixes #3409 For #3411 Change-Id: Ib8177cda8c79a7251cb11f26ea3def18630f3858 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/588757 Commit-Queue: Hyang-Ah Hana Kim <[email protected]> Reviewed-by: Suzy Mueller <[email protected]> kokoro-CI: kokoro <[email protected]>
1 parent 65d72fd commit 1d1fe76

File tree

6 files changed

+32
-25
lines changed

6 files changed

+32
-25
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ provides rich language support for the
1111
## Requirements
1212

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

1616
## Quick Start
1717

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

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

2424
1. Install the [VS Code Go extension].
2525

extension/src/goInstallTools.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,12 @@ export async function installTools(
164164
});
165165
}
166166

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

801801
export async function suggestUpdates() {
802802
const configuredGoVersion = await getGoVersion();
803-
if (!configuredGoVersion || configuredGoVersion.lt('1.16')) {
803+
if (!configuredGoVersion || configuredGoVersion.lt('1.19')) {
804804
// User is using an ancient or a dev version of go. Don't suggest updates -
805805
// user should know what they are doing.
806806
return;
@@ -876,12 +876,12 @@ export async function listOutdatedTools(configuredGoVersion: GoVersion | undefin
876876
// We test the inequality by checking whether the exact beta or rc version
877877
// appears in the `go version` output. e.g.,
878878
// configuredGoVersion.version goVersion(tool) update
879-
// 'go version go1.18 ...' 'go1.18beta1' Yes
880-
// 'go version go1.18beta1 ...' 'go1.18beta1' No
881-
// 'go version go1.18beta2 ...' 'go1.18beta1' Yes
882-
// 'go version go1.18rc1 ...' 'go1.18beta1' Yes
883-
// 'go version go1.18rc1 ...' 'go1.18' No
884-
// 'go version devel go1.18-deadbeaf ...' 'go1.18beta1' No (* rare)
879+
// 'go version go1.21 ...' 'go1.21beta1' Yes
880+
// 'go version go1.21beta1 ...' 'go1.21beta1' No
881+
// 'go version go1.21beta2 ...' 'go1.21beta1' Yes
882+
// 'go version go1.21rc1 ...' 'go1.21beta1' Yes
883+
// 'go version go1.21rc1 ...' 'go1.21' No
884+
// 'go version devel go1.21-deadbeaf ...' 'go1.21beta1' No (* rare)
885885
!configuredGoVersion.version.includes(goVersion)
886886
) {
887887
return tool;

extension/src/goTools.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,24 @@ export function getImportPathWithVersion(
6969
return importPath + '@' + version;
7070
}
7171
}
72+
if (tool.name === 'gopls') {
73+
if (goVersion.lt('1.19')) return importPath + '@v0.14.2';
74+
if (goVersion.lt('1.21')) return importPath + '@v0.15.3';
75+
}
76+
if (tool.name === 'dlv') {
77+
if (goVersion.lt('1.19')) return importPath + '@v1.20.2';
78+
if (goVersion.lt('1.21')) return importPath + '@v1.22.1';
79+
}
7280
if (tool.name === 'staticcheck') {
73-
if (goVersion.lt('1.17')) return importPath + '@v0.2.2';
7481
if (goVersion.lt('1.19')) return importPath + '@v0.3.3';
82+
if (goVersion.lt('1.21')) return importPath + '@v0.4.7';
7583
}
7684
if (tool.name === 'gofumpt') {
77-
if (goVersion.lt('1.18')) return importPath + '@v0.2.1';
7885
if (goVersion.lt('1.19')) return importPath + '@v0.4.0';
7986
if (goVersion.lt('1.20')) return importPath + '@v0.5.0';
87+
if (goVersion.lt('1.21')) return importPath + '@v0.6.0';
8088
}
8189
if (tool.name === 'golangci-lint') {
82-
if (goVersion.lt('1.18')) return importPath + '@v1.47.3';
8390
if (goVersion.lt('1.20')) return importPath + '@v1.53.3';
8491
if (goVersion.lt('1.21')) return importPath + '@v1.55.2';
8592
}

extension/src/goToolsInformation.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@ export const allToolsInformation: { [key: string]: Tool } = {
102102
isImportant: true,
103103
description: 'Language Server from Google',
104104
usePrereleaseInPreviewMode: true,
105-
minimumGoVersion: semver.coerce('1.18'),
106-
latestVersion: semver.parse('v0.14.2'),
107-
latestVersionTimestamp: moment('2023-11-14', 'YYYY-MM-DD'),
108-
latestPrereleaseVersion: semver.parse('v0.14.2'),
109-
latestPrereleaseVersionTimestamp: moment('2023-11-14', 'YYYY-MM-DD')
105+
minimumGoVersion: semver.coerce('1.19'),
106+
latestVersion: semver.parse('v0.15.3'),
107+
latestVersionTimestamp: moment('2024-04-12', 'YYYY-MM-DD'),
108+
latestPrereleaseVersion: semver.parse('v0.15.3'),
109+
latestPrereleaseVersionTimestamp: moment('2024-04-12', 'YYYY-MM-DD')
110110
},
111111
'dlv': {
112112
name: 'dlv',

extension/tools/allTools.ts.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const allToolsInformation: { [key: string]: Tool } = {
3737
replacedByGopls: true,
3838
isImportant: false,
3939
description: 'Formatter',
40-
defaultVersion: 'v0.5.0'
40+
defaultVersion: 'v0.6.0'
4141
},
4242
'goimports': {
4343
name: 'goimports',
@@ -100,7 +100,7 @@ export const allToolsInformation: { [key: string]: Tool } = {
100100
isImportant: true,
101101
description: 'Language Server from Google',
102102
usePrereleaseInPreviewMode: true,
103-
minimumGoVersion: semver.coerce('1.18'),
103+
minimumGoVersion: semver.coerce('1.19'),
104104
latestVersion: semver.parse('%s'),
105105
latestVersionTimestamp: moment('%s', 'YYYY-MM-DD'),
106106
latestPrereleaseVersion: semver.parse('%s'),
@@ -122,7 +122,7 @@ export const allToolsInformation: { [key: string]: Tool } = {
122122
importPath: 'github.com/golang/vscode-go/vscgo',
123123
modulePath: 'github.com/golang/vscode-go/vscgo',
124124
replacedByGopls: false,
125-
isImportant: false, // TODO: set to true when we need it
125+
isImportant: false, // TODO: set to true when we need it
126126
description: 'VS Code Go helper program',
127127
minimumGoVersion: semver.coerce('1.18')
128128
}

extension/tools/installtools/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ var tools = []struct {
3838
{"golang.org/x/tools/gopls", "", true, nil},
3939
{"github.com/cweill/gotests/gotests", "", false, nil},
4040
{"github.com/haya14busa/goplay/cmd/goplay", "", false, nil},
41-
{"honnef.co/go/tools/cmd/staticcheck", "", false, []finalVersion{{16, "v0.2.2"}, {18, "v0.3.3"}}},
42-
{"github.com/go-delve/delve/cmd/dlv", "", false, []finalVersion{{16, "v1.8.3"}, {17, "v1.9.1"}, {18, "v1.20.2"}}},
41+
{"honnef.co/go/tools/cmd/staticcheck", "", false, []finalVersion{{18, "v0.3.3"}, {20, "v0.4.7"}}},
42+
{"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"}}},
4343
}
4444

4545
// pickVersion returns the version to install based on the supported

0 commit comments

Comments
 (0)