Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.