Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

check the gopls version and update if outdated #2719

Merged
merged 59 commits into from
Sep 6, 2019
Merged

check the gopls version and update if outdated #2719

merged 59 commits into from
Sep 6, 2019

Conversation

stamblerre
Copy link
Contributor

Sorry about the huge diff, this PR is actually stacked on top of all of my previous ones. The main interesting change is at the very end of the goLanguageServer.ts file, where we detect the gopls version and determine if it is the most recent one.

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Sep 1, 2019

@stamblerre If the main change is only in the goLanguageServer.ts file, then I would suggest to close this PR and make the relevant changes in your other PR #2703 or wait till #2703 is merged and then create a new PR

Your older PR #2701 has been merged and I have updated PR #2703 with the latest changes from the master branch along with a few other fixes

@stamblerre
Copy link
Contributor Author

This change adds a few dependencies, so I figured it would make sense to logically separate it from the previous one. I'm happy to wait for #2703 to be merged, and then I can resolve the merge conflicts so that you can review this one. Thanks!

@ramya-rao-a
Copy link
Contributor

@stamblerre Your other PRs have been merged to master. Once you resolve the merge conflicts in this PR, I'll start reviewing.

@stamblerre
Copy link
Contributor Author

Thanks for the reviews! I just resolved the merge conflicts here, so this change is ready for review.

@@ -112,7 +112,7 @@ export function installTools(missing: Tool[], goVersion: SemVersion): Promise<vo
// This ensures that users get the latest tagged version, rather than master,
// which may be unstable.
let modulesOff = false;
if (isBelow(goVersion, 1, 11)) {
if (semver.lt(goVersion, '1.11.0')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does semver.lt behave when the first argument is null?
Same question for gt or other comparison functions that are being used.

In our case goVersion will be null when using Go from the tip
You will need to add a null check on goVersion every time we use the lt, gt function

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reworked some of the Go version handling to tackle developer versions. There's definitely more that can be done to improve handling, but this should work for now.

//
// golang.org/x/tools/gopls@v0.1.3
//
const split = moduleVersion.trim().split('@');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moduleVersion can be undefined if lines[1] had no ' '

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe it would ever be. I tested a few cases, and in the case where there is no element to split on, split just returns an array of 1 element containing the original string.

@@ -6,8 +6,9 @@
import vscode = require('vscode');
import cp = require('child_process');
import path = require('path');
import semver = require('semver');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import is no longer used.

Suggested change
import semver = require('semver');

src/goTools.ts Outdated
@@ -5,8 +5,9 @@

'use strict';

import { SemVersion, isAbove, getGoConfig, isBelow } from './util';
import vscode = require('vscode');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import is not needed.

Suggested change
import vscode = require('vscode');

src/goVet.ts Outdated
@@ -4,8 +4,9 @@
*--------------------------------------------------------*/

import path = require('path');
import semver = require('semver');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import no longer needed.

Suggested change
import semver = require('semver');

src/testUtils.ts Outdated
@@ -6,6 +6,7 @@ import cp = require('child_process');
import path = require('path');
import util = require('util');
import vscode = require('vscode');
import semver = require('semver');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import no longer needed.

Suggested change
import semver = require('semver');

@stamblerre
Copy link
Contributor Author

Fixed all the unused imports, sorry about that. I wonder why the linter didn't report them.

src/util.ts Outdated Show resolved Hide resolved
src/goLanguageServer.ts Outdated Show resolved Hide resolved
@ramya-rao-a ramya-rao-a merged commit 461c79d into microsoft:master Sep 6, 2019
@stamblerre stamblerre deleted the primary branch September 9, 2019 18:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants