Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

snippets: add errp for error panic #926

Merged
merged 1 commit into from
Jul 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions gosnippets/UltiSnips/go.snippets
Original file line number Diff line number Diff line change
Expand Up @@ -151,21 +151,31 @@ if err != nil {
${0}
endsnippet

# error snippet
snippet errt "Error test fatal " !b
# error multiple return
snippet errn, "Error return with two return values" !b
if err != nil {
t.Fatal(err)
return ${1:nil}, err
}
${0}
endsnippet

snippet errn, "Error return with two return values" !b
# error panic
snippet errp "Error panic !b
if err != nil {
return ${1:nil}, err
panic(${1})
}
${0}
endsnippet

# error test
snippet errt "Error test fatal " !b
if err != nil {
t.Fatal(err)
}
${0}
endsnippet

# error handle
snippet errh "Error handle and return" !b
if err != nil {
${1}
Expand Down
8 changes: 8 additions & 0 deletions gosnippets/snippets/go.snip
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,14 @@ abbr if err != nil { return }
}
${0}

# error snippet with panic
snippet errp
abbr if err != nil { ... }
if err != nil {
panic(${1})
}
${0}

# json snippet
snippet json
abbr \`json:key\`
Expand Down