compiler go
noremap <buffer> <space> :silent make <bar> redraw

let g:ale_linters = {
            \    'go': ['gopls'],
            \}

" let g:ale_completion_enabled = 1

" Map <Leader>ee to insert Go error handling if condition
nnoremap <Leader>ee :call InsertGoErrorHandling()<CR>

function! InsertGoErrorHandling()
    let err_handling = "if err != nil { \r    return err \r}"

    let save_cursor = getpos(".")
    execute "normal! a" . err_handling
    normal! jjj$
    normal! $o
    startinsert
endfunction