Skip to content

Commit

Permalink
Merge pull request #2883 from swithek/error-snippets
Browse files Browse the repository at this point in the history
snippets: add fmt.Errorf error wrapping snippets
  • Loading branch information
bhcleek committed May 25, 2020
2 parents 6c9531d + cfc3017 commit f8fe1fd
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions gosnippets/UltiSnips/go.snippets
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,18 @@ snippet fe "fmt.Errorf(...)"
fmt.Errorf("${1:${VISUAL}}")
endsnippet

# Fmt Errorf wrap
snippet few "fmt.Errorf(%w, err)"
fmt.Errorf("${1:message}: %w", ${2:${VISUAL:err}})
endsnippet

# Fmt Errorf wrap and return
snippet errnfw "Error return fmt.Errorf(%w, err)" !b
if ${1:${VISUAL:err}} != nil {
return fmt.Errorf("${2:message}: %w", $1)
}
endsnippet

# log printf
snippet lf "log.Printf(...)"
log.Printf("${1:${VISUAL}} = %+v\n", $1)
Expand Down

0 comments on commit f8fe1fd

Please sign in to comment.