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

fix: #1026 remove go 1.5 support #2319

Merged
merged 4 commits into from
Mar 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/goDeclaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export function definitionLocation(document: vscode.TextDocument, position: vsco
cwd: (modFolderPath && modFolderPath !== getModuleCache())
? modFolderPath : (getWorkspaceFolderPath(document.uri) || path.dirname(document.fileName))
};
if (toolForDocs === 'godoc' || (ver && (ver.major < 1 || (ver.major === 1 && ver.minor < 6)))) {
if (toolForDocs === 'godoc') {
return definitionLocation_godef(input, token);
} else if (toolForDocs === 'guru') {
return definitionLocation_guru(input, token);
Expand Down
43 changes: 12 additions & 31 deletions src/goInstallTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ function getTools(goVersion: SemVersion): string[] {
// Install the doc/def tool that was chosen by the user
if (goConfig['docsTool'] === 'godoc') {
tools.push('godef');
} else if (goConfig['docsTool'] === 'gogetdoc') {
tools.push('gogetdoc');
}

// Install the formattool that was chosen by the user
Expand All @@ -108,30 +110,13 @@ function getTools(goVersion: SemVersion): string[] {
tools.push('goreturns');
}

// Tools not supported in go1.8
if (!goVersion || (goVersion.major > 1 || (goVersion.major === 1 && goVersion.minor > 8))) {
if (goConfig['lintTool'] === 'golint') {
tools.push('golint');
}
if (goConfig['docsTool'] === 'gogetdoc') {
tools.push('gogetdoc');
}
}

if (goConfig['lintTool'] === 'gometalinter') {
tools.push('gometalinter');
}

if (goConfig['lintTool'] === 'staticcheck') {
tools.push('staticcheck');
}

if (goConfig['lintTool'] === 'golangci-lint') {
tools.push('golangci-lint');
}

if (goConfig['lintTool'] === 'revive') {
tools.push('revive');
// Install the linter that was chosen by the user
if (goConfig['lintTool'] === 'golint'
|| goConfig['lintTool'] === 'gometalinter'
|| goConfig['lintTool'] === 'staticcheck'
|| goConfig['lintTool'] === 'golangci-lint'
|| goConfig['lintTool'] === 'revive') {
tools.push(goConfig['lintTool']);
}

if (goConfig['useLanguageServer']) {
Expand All @@ -142,12 +127,8 @@ function getTools(goVersion: SemVersion): string[] {
tools.push('gotype-live');
}

// gotests is not supported in go1.5
if (!goVersion || (goVersion.major > 1 || (goVersion.major === 1 && goVersion.minor > 5))) {
tools.push('gotests');
}

tools.push(
'gotests',
'gomodifytags',
'impl',
'fillstruct',
Expand Down Expand Up @@ -213,13 +194,13 @@ export function promptForMissingTool(tool: string) {
return;
}
getGoVersion().then((goVersion) => {
if (goVersion && goVersion.major === 1 && goVersion.minor < 6) {
if (goVersion && goVersion.major === 1 && goVersion.minor < 9) {
if (tool === 'golint') {
vscode.window.showInformationMessage('golint no longer supports go1.8, update your settings to use gometalinter as go.lintTool and install gometalinter');
return;
}
if (tool === 'gotests') {
vscode.window.showInformationMessage('Generate unit tests feature is not supported as gotests tool needs go1.6 or higher.');
vscode.window.showInformationMessage('Generate unit tests feature is not supported as gotests tool needs go1.9 or higher.');
Copy link
Contributor

Choose a reason for hiding this comment

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

Has gotests really stopped supported versions below 1.9?

return;
}
}
Expand Down
45 changes: 3 additions & 42 deletions test/go.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,7 @@ suite('Go Extension Tests', () => {
let config = Object.create(vscode.workspace.getConfiguration('go'), {
'docsTool': { value: 'gogetdoc' }
});
getGoVersion().then(version => {
if (!version || version.major > 1 || (version.major === 1 && version.minor > 8)) {
return testDefinitionProvider(config);
}
return Promise.resolve();
}).then(() => done(), done);
testDefinitionProvider(config).then(() => done(), done);
}).timeout(10000);

test('Test SignatureHelp Provider using godoc', (done) => {
Expand Down Expand Up @@ -208,12 +203,7 @@ It returns the number of bytes written and any write error encountered.
let config = Object.create(vscode.workspace.getConfiguration('go'), {
'docsTool': { value: 'gogetdoc' }
});
getGoVersion().then(version => {
if (!version || version.major > 1 || (version.major === 1 && version.minor > 8)) {
return testSignatureHelpProvider(config, testCases);
}
return Promise.resolve();
}).then(() => done(), done);
testSignatureHelpProvider(config, testCases).then(() => done(), done);
}).timeout(10000);

test('Test Hover Provider using godoc', (done) => {
Expand Down Expand Up @@ -264,12 +254,7 @@ It returns the number of bytes written and any write error encountered.
let config = Object.create(vscode.workspace.getConfiguration('go'), {
'docsTool': { value: 'gogetdoc' }
});
getGoVersion().then(version => {
if (!version || version.major > 1 || (version.major === 1 && version.minor > 8)) {
return testHoverProvider(config, testCases);
}
return Promise.resolve();
}).then(() => done(), done);
testHoverProvider(config, testCases).then(() => done(), done);
}).timeout(10000);

test('Error checking', (done) => {
Expand All @@ -286,10 +271,6 @@ It returns the number of bytes written and any write error encountered.
{ line: 11, severity: 'error', msg: 'undefined: prin' },
];
getGoVersion().then(version => {
if (version && version.major === 1 && version.minor < 9) {
// golint supports only latest 3 versions, so skip the test
return Promise.resolve();
}
return check(vscode.Uri.file(path.join(fixturePath, 'errorsTest', 'errors.go')), config).then(diagnostics => {
const allDiagnostics = [].concat.apply([], diagnostics.map(x => x.errors));
let sortedDiagnostics = allDiagnostics.sort((a: any, b: any) => a.line - b.line);
Expand Down Expand Up @@ -317,11 +298,6 @@ It returns the number of bytes written and any write error encountered.
}

getGoVersion().then(version => {
if (version && version.major === 1 && version.minor < 6) {
// gotests is not supported in Go 1.5, so skip the test
return Promise.resolve();
}

let uri = vscode.Uri.file(path.join(generateTestsSourcePath, 'generatetests.go'));
return vscode.workspace.openTextDocument(uri).then(document => {
return vscode.window.showTextDocument(document).then(editor => {
Expand All @@ -348,11 +324,6 @@ It returns the number of bytes written and any write error encountered.
}

getGoVersion().then(version => {
if (version && version.major === 1 && version.minor < 6) {
// gotests is not supported in Go 1.5, so skip the test
return Promise.resolve();
}

let uri = vscode.Uri.file(path.join(generateFunctionTestSourcePath, 'generatetests.go'));
return vscode.workspace.openTextDocument(uri).then(document => {
return vscode.window.showTextDocument(document).then((editor: vscode.TextEditor) => {
Expand Down Expand Up @@ -382,11 +353,6 @@ It returns the number of bytes written and any write error encountered.
}

getGoVersion().then(version => {
if (version && version.major === 1 && version.minor < 6) {
// gotests is not supported in Go 1.5, so skip the test
return Promise.resolve();
}

let uri = vscode.Uri.file(path.join(generatePackageTestSourcePath, 'generatetests.go'));
return vscode.workspace.openTextDocument(uri).then(document => {
return vscode.window.showTextDocument(document).then(editor => {
Expand All @@ -408,11 +374,6 @@ It returns the number of bytes written and any write error encountered.

test('Gometalinter error checking', (done) => {
getGoVersion().then(version => {
if (version && version.major === 1 && version.minor < 6) {
// golint in gometalinter is not supported in Go 1.5, so skip the test
return Promise.resolve();
}

let config = Object.create(vscode.workspace.getConfiguration('go'), {
'lintOnSave': { value: 'package' },
'lintTool': { value: 'gometalinter' },
Expand Down