diff --git a/src/goCheck.ts b/src/goCheck.ts index 2cddb367..36471f74 100644 --- a/src/goCheck.ts +++ b/src/goCheck.ts @@ -231,11 +231,10 @@ export function check(filename: string, goConfig: vscode.WorkspaceConfiguration) if (!!goConfig['vetOnSave'] && goConfig['vetOnSave'] !== 'off') { let vetFlags = goConfig['vetFlags'] || []; - let vetArgs = ['vet', ...vetFlags]; + let vetArgs = ['tool', 'vet', ...vetFlags, '.']; let vetWorkDir = cwd; if (goConfig['vetOnSave'] === 'workspace') { - vetArgs.push('./...'); vetWorkDir = vscode.workspace.rootPath; } diff --git a/test/fixtures/errorsTest/errors.go b/test/fixtures/errorsTest/errors.go index 18d6162d..f9702abd 100644 --- a/test/fixtures/errorsTest/errors.go +++ b/test/fixtures/errorsTest/errors.go @@ -6,6 +6,7 @@ import ( func Print2(txt string) { fmt.Println(txt) + fmt.Println("%s") } func main2() { prin("Hello") diff --git a/test/go.test.ts b/test/go.test.ts index aaf3044c..1c1ae5a5 100644 --- a/test/go.test.ts +++ b/test/go.test.ts @@ -293,11 +293,16 @@ It returns the number of bytes written and any write error encountered. }); test('Error checking', (done) => { - let config = vscode.workspace.getConfiguration('go'); + let config = Object.create(vscode.workspace.getConfiguration('go'), { + 'vetOnSave': { value: 'package' }, + 'vetFlags': { value: ['-all'] }, + 'lintTool': { value: 'golint' }, + 'lintFlags': { value: [] } + }); let expected = [ { line: 7, severity: 'warning', msg: 'exported function Print2 should have comment or be unexported' }, - // { line: 7, severity: 'warning', msg: 'no formatting directive in Printf call' }, - { line: 11, severity: 'error', msg: 'undefined: prin' }, + { line: 9, severity: 'warning', msg: 'possible formatting directive in Println call' }, + { line: 12, severity: 'error', msg: 'undefined: prin' }, ]; getGoVersion().then(version => { if (version.major === 1 && version.minor < 6) { @@ -409,12 +414,13 @@ It returns the number of bytes written and any write error encountered. let config = Object.create(vscode.workspace.getConfiguration('go'), { 'lintTool': { value: 'gometalinter' }, - 'lintFlags': { value: ['--disable-all', '--enable=varcheck', '--enable=errcheck']} + 'lintFlags': { value: ['--disable-all', '--enable=varcheck', '--enable=errcheck'] }, + 'vetOnSave': { value: 'off' }, + 'buildOnSave': { value: 'off' } }); let expected = [ - { line: 11, severity: 'warning', msg: 'error return value not checked (undeclared name: prin) (errcheck)' }, - { line: 11, severity: 'error', msg: 'undefined: prin' }, - { line: 11, severity: 'warning', msg: 'unused variable or constant undeclared name: prin (varcheck)' }, + { line: 12, severity: 'warning', msg: 'error return value not checked (undeclared name: prin) (errcheck)' }, + { line: 12, severity: 'warning', msg: 'unused variable or constant undeclared name: prin (varcheck)' }, ]; return check(path.join(fixturePath, 'errorsTest', 'errors.go'), config).then(diagnostics => { let sortedDiagnostics = diagnostics.sort((a, b) => {