Skip to content

Instantly share code, notes, and snippets.

@jonmorehouse
Last active August 29, 2015 13:55
Show Gist options
  • Save jonmorehouse/8762219 to your computer and use it in GitHub Desktop.
Save jonmorehouse/8762219 to your computer and use it in GitHub Desktop.
Go test runner for vim editor
fu! GoTestPackage()
let command = "go test ."
call CleanShell(command)
endfunction
fu! GoTestFile()
if @% !~ ".go"
return
elseif @% =~ "_test.go"
let file = @%
else
let file = split(@%, ".go")[0] . "_test.go"
endif
" now run go tests
let command = "go test -v " . file
" now run this command
call CleanShell(command)
endfunction
map <Leader>rr :call GoTestFile()<CR>
map <Leader>r :call GoTestPackage()<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment