diff --git a/src/goLanguageServer.ts b/src/goLanguageServer.ts index 6409077e..25d3eed8 100644 --- a/src/goLanguageServer.ts +++ b/src/goLanguageServer.ts @@ -507,13 +507,19 @@ async function latestGopls(tool: Tool): Promise { // Coerce the versions into SemVers so that they can be sorted correctly. const versions = []; for (const version of data.trim().split('\n')) { - versions.push(semver.coerce(version)); + const parsed = semver.parse(version, { + includePrerelease: true, + loose: true, + }); + versions.push(parsed); } if (versions.length === 0) { return null; } versions.sort(semver.rcompare); - return versions[0]; + + // The first version in the sorted list without a prerelease tag. + return versions.find(version => !version.prerelease || !version.prerelease.length); } async function goplsVersion(goplsPath: string): Promise { @@ -594,7 +600,7 @@ async function goProxyRequest(tool: Tool, endpoint: string): Promise { return null; } -function goProxy(): string[] { +function goProxy(): string[] { const output: string = process.env['GOPROXY']; if (!output || !output.trim()) { return [];