Last active
August 16, 2023 05:29
-
-
Save wheelercj/bf587be7e1de4351c96f92929d840ce4 to your computer and use it in GitHub Desktop.
VS Code snippet for Golang to return err if it's not nil. Just press alt+/ to insert the commonly used err-returning code.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Return err if it's not nil": { | |
"prefix": "e?", | |
"body": [ | |
"${TM_CURRENT_LINE/^(\\s*e\\?)|(\\s*if .+)|(\\s*)/${1:+if }${2:+ }${3:+if }/}err != nil {", | |
"\treturn${2} err", | |
"}", | |
] | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"key": "alt+/", | |
"command": "editor.action.insertSnippet", | |
"when": "editorTextFocus", | |
"args": { | |
"name": "Return err if it's not nil" | |
} | |
} | |
] |
Author
wheelercj
commented
Aug 16, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment