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

Update go vet for go 1.10 recommendations #1576

Merged
merged 1 commit into from
Mar 15, 2018
Merged
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
35 changes: 20 additions & 15 deletions src/goVet.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path = require('path');
import vscode = require('vscode');
import { getToolsEnvVars, runTool, ICheckResult, handleDiagnosticErrors, getWorkspaceFolderPath } from './util';
import { getToolsEnvVars, runTool, ICheckResult, handleDiagnosticErrors, getWorkspaceFolderPath, getGoVersion, SemVersion } from './util';
import { outputChannel } from './goStatus';
import { diagnosticsStatusBarItem } from './goStatus';

Expand Down Expand Up @@ -56,21 +56,26 @@ export function goVet(fileUri: vscode.Uri, goConfig: vscode.WorkspaceConfigurati

const vetFlags = goConfig['vetFlags'] || [];
const vetEnv = Object.assign({}, getToolsEnvVars());
const vetArgs = vetFlags.length ? ['tool', 'vet', ...vetFlags, '.'] : ['vet', './...'];
const vetPromise = getGoVersion().then((version: SemVersion) => {
let vetArgs = vetFlags.length ? ['tool', 'vet', ...vetFlags, '.'] : ['vet', './...'];
if (version && vetFlags.length) {
vetArgs = version.major === 1 && version.minor <= 9 ? vetArgs : vetArgs.slice(1);
}

running = true;
const vetPromise = runTool(
vetArgs,
cwd,
'warning',
true,
null,
vetEnv,
false,
tokenSource.token
).then((result) => {
running = false;
return result;
running = true;
return runTool(
vetArgs,
cwd,
'warning',
true,
null,
vetEnv,
false,
tokenSource.token
).then((result) => {
running = false;
return result;
});
});

return vetPromise;
Expand Down