From c222a5d14973c5474d36857b032cecdd263fe443 Mon Sep 17 00:00:00 2001 From: Sardorbek Pulatov Date: Sun, 10 Feb 2019 09:11:54 +0100 Subject: [PATCH 1/4] fix: #1026 remove go 1.5 support --- src/goDeclaration.ts | 2 +- src/goInstallTools.ts | 4 ++-- test/go.test.ts | 22 ++-------------------- 3 files changed, 5 insertions(+), 23 deletions(-) diff --git a/src/goDeclaration.ts b/src/goDeclaration.ts index b6d0d7824..09d1d0b09 100644 --- a/src/goDeclaration.ts +++ b/src/goDeclaration.ts @@ -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); diff --git a/src/goInstallTools.ts b/src/goInstallTools.ts index 2806db8b4..bad94b2ad 100644 --- a/src/goInstallTools.ts +++ b/src/goInstallTools.ts @@ -213,13 +213,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.'); return; } } diff --git a/test/go.test.ts b/test/go.test.ts index 60178cc5c..400e4b812 100644 --- a/test/go.test.ts +++ b/test/go.test.ts @@ -24,6 +24,7 @@ import { getAllPackages } from '../src/goPackages'; import { getImportPath } from '../src/util'; import { goPlay } from '../src/goPlayground'; import { runFillStruct } from '../src/goFillStruct'; +import { version } from 'punycode'; suite('Go Extension Tests', () => { let gopath = process.env['GOPATH']; @@ -290,6 +291,7 @@ It returns the number of bytes written and any write error encountered. // 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); @@ -317,11 +319,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 => { @@ -348,11 +345,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) => { @@ -382,11 +374,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 => { @@ -408,11 +395,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' }, From e8f61d9b3763993aca14feafca3b368fe051997b Mon Sep 17 00:00:00 2001 From: Ramya Achutha Rao Date: Sat, 2 Mar 2019 13:59:24 -0800 Subject: [PATCH 2/4] Extension developers are less likely to work on really old versions of Go --- test/go.test.ts | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/test/go.test.ts b/test/go.test.ts index 400e4b812..490521888 100644 --- a/test/go.test.ts +++ b/test/go.test.ts @@ -163,12 +163,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) => { @@ -209,12 +204,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) => { @@ -265,12 +255,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) => { @@ -287,11 +272,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); From 741aaa2a01527e91ba48c275e2945e268050c273 Mon Sep 17 00:00:00 2001 From: Ramya Achutha Rao Date: Sat, 2 Mar 2019 13:59:34 -0800 Subject: [PATCH 3/4] Simplify tool management --- src/goInstallTools.ts | 39 ++++++++++----------------------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/src/goInstallTools.ts b/src/goInstallTools.ts index bad94b2ad..bdeb550ad 100644 --- a/src/goInstallTools.ts +++ b/src/goInstallTools.ts @@ -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 @@ -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']) { @@ -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', From 6ffbc24f56996e484e37d7e1433cb1a7dba531b2 Mon Sep 17 00:00:00 2001 From: Ramya Achutha Rao Date: Sat, 2 Mar 2019 13:59:54 -0800 Subject: [PATCH 4/4] Remove unsued import --- test/go.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/test/go.test.ts b/test/go.test.ts index 490521888..31e1da05a 100644 --- a/test/go.test.ts +++ b/test/go.test.ts @@ -24,7 +24,6 @@ import { getAllPackages } from '../src/goPackages'; import { getImportPath } from '../src/util'; import { goPlay } from '../src/goPlayground'; import { runFillStruct } from '../src/goFillStruct'; -import { version } from 'punycode'; suite('Go Extension Tests', () => { let gopath = process.env['GOPATH'];