Run golang tests in vim.
Add this to your .vimrc
or inside .vim/ftplugin/go.vim
if you want only use this mapping with files that have the go
filetype.
map <Leader>ra :wa<CR> :GolangTestCurrentPackage<CR>
map <Leader>rf :wa<CR> :GolangTestFocused<CR>
GolangTestFocused
will find the first func
above your current line that starts with Test
and run that with go test -run <test name>
. If you're using examples this plugin will use -examples.run
rather than -run
.
This plugin assumes you will be testing the local package. For example if you run GolangTestCurrentPackage
the resulting command would be: go test -v .
.
With vim-bundle: vim-bundle install benmills/vimux-golang
Otherwise download the latest tarball, extract it and move plugin/vimux-golang.vim
inside ~/.vim/plugin
. If you're using pathogen, then move the entire folder extracted from the tarball into ~/.vim/bundle
.