From 0f564c5ff2e7847de39a51cd3bd1b4c587f3266e Mon Sep 17 00:00:00 2001 From: Hana Date: Wed, 26 Jan 2022 22:34:17 -0500 Subject: [PATCH] src/goToolsInformation: require go1.13+ for gopls Gopls v0.8.0+ will require go1.13+ for build. And, skip gopls shouldUpdateLanguageServer check. Fixes golang/vscode-go#2030 Change-Id: If8fdc14553337c4a9bb3f8caae15ace2aa60e0eb --- src/goLanguageServer.ts | 6 ++++++ src/goToolsInformation.ts | 3 ++- test/testdata/helloWorldServer/go.mod | 2 +- tools/allTools.ts.in | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/goLanguageServer.ts b/src/goLanguageServer.ts index 69b80884d1..bb0be8d75c 100644 --- a/src/goLanguageServer.ts +++ b/src/goLanguageServer.ts @@ -1072,6 +1072,12 @@ export async function shouldUpdateLanguageServer( return null; } + // If the Go version is too old, don't update. + const goVersion = await getGoVersion(); + if (!goVersion || (tool.minimumGoVersion && goVersion.lt(tool.minimumGoVersion.format()))) { + return null; + } + // First, run the "gopls version" command and parse its results. // TODO(rstambler): Confirm that the gopls binary's modtime matches the // modtime in the config. Update it if needed. diff --git a/src/goToolsInformation.ts b/src/goToolsInformation.ts index 5df956c169..892b18d0db 100644 --- a/src/goToolsInformation.ts +++ b/src/goToolsInformation.ts @@ -202,7 +202,7 @@ export const allToolsInformation: { [key: string]: Tool } = { isImportant: true, description: 'Language Server from Google', usePrereleaseInPreviewMode: true, - minimumGoVersion: semver.coerce('1.12'), + minimumGoVersion: semver.coerce('1.13'), latestVersion: semver.parse('v0.7.5'), latestVersionTimestamp: moment('2022-01-18', 'YYYY-MM-DD'), latestPrereleaseVersion: semver.parse('v0.7.5'), @@ -236,3 +236,4 @@ export const allToolsInformation: { [key: string]: Tool } = { description: 'Extract to functions and variables' } }; + diff --git a/test/testdata/helloWorldServer/go.mod b/test/testdata/helloWorldServer/go.mod index 602e8b29cc..64a8a23a37 100644 --- a/test/testdata/helloWorldServer/go.mod +++ b/test/testdata/helloWorldServer/go.mod @@ -1,3 +1,3 @@ module hello-world -go 1.12 +go 1.13 diff --git a/tools/allTools.ts.in b/tools/allTools.ts.in index b08805419b..237c9eb016 100644 --- a/tools/allTools.ts.in +++ b/tools/allTools.ts.in @@ -200,7 +200,7 @@ export const allToolsInformation: { [key: string]: Tool } = { isImportant: true, description: 'Language Server from Google', usePrereleaseInPreviewMode: true, - minimumGoVersion: semver.coerce('1.12'), + minimumGoVersion: semver.coerce('1.13'), latestVersion: semver.parse('%s'), latestVersionTimestamp: moment('%s', 'YYYY-MM-DD'), latestPrereleaseVersion: semver.parse('%s'),