Skip to content

Instantly share code, notes, and snippets.

@sent-hil
Created August 18, 2013 03:33
Show Gist options
  • Save sent-hil/6259773 to your computer and use it in GitHub Desktop.
Save sent-hil/6259773 to your computer and use it in GitHub Desktop.
Run go test under cursor
function RunGoTestUnderLine()
let line_text = getline(".")
let raw_test_name = matchstr(getline("."), "Test.*\(")
if raw_test_name != -1
let test_name = substitute(raw_test_name, "\(", "", "")
exec '!go test -run ' . test_name
endif
endfunction
autocmd FileType go nnoremap <leader>s :call RunGoTestUnderLine()<cr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment