Vim-go: :GoBuild on save .go and :GoTest on save _test.go

Created on 29 Jun 2017  路  4Comments  路  Source: fatih/vim-go

Proposal:

What if there be some settings which allow automatically start

GoBuild on save ".go" file and GoTes on save "_test.go" file.

I would be happy about it.

Most helpful comment

You can already add this yourself with an autocmd; for example:

" Build/Test on save.
augroup auto_go
    autocmd!
    autocmd BufWritePost *.go :GoBuild
    autocmd BufWritePost *_test.go :GoTest
augroup end

In addition, I think you can use gometalinter to run tests too (let g:go_metalinter_autosave_enabled = ['test', 'vet', 'golint']? Didn't test).

All 4 comments

You can already add this yourself with an autocmd; for example:

" Build/Test on save.
augroup auto_go
    autocmd!
    autocmd BufWritePost *.go :GoBuild
    autocmd BufWritePost *_test.go :GoTest
augroup end

In addition, I think you can use gometalinter to run tests too (let g:go_metalinter_autosave_enabled = ['test', 'vet', 'golint']? Didn't test).

g:go_metalinter_autosave_enabled ['vet', 'golint', 'test']
doesn't work for me

Did you read the documentation? I have no idea if that is a valid setting, but from memory I believe something like that should work (I could be mistaken!)

Either way, the autocmd should work for you.

Hi @korjavin

There is no autobuild by default, you can use the command that @Carpetsmoker provided. Also the following indeed works for me

let g:go_metalinter_autosave_enabled = ['vet', 'golint', 'test']

In your case the = is missing (not sure if that is related). Thanks for the feedback.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MattFlower picture MattFlower  路  4Comments

smontazeran picture smontazeran  路  4Comments

derekchiang picture derekchiang  路  3Comments

preslavmihaylov picture preslavmihaylov  路  3Comments

wpaulino picture wpaulino  路  4Comments