Created
October 11, 2016 18:33
-
-
Save mattetti/11b01f99eb22caceddb46cb51e926255 to your computer and use it in GitHub Desktop.
Go snippet for VSCode
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
{ | |
/* | |
// Place your snippets for Go here. Each snippet is defined under a snippet name and has a prefix, body and | |
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are: | |
// $1, $2 for tab stops, ${id} and ${id:label} and ${1:label} for variables. Variables with the same id are connected. | |
// Example: | |
"Print to console": { | |
"prefix": "log", | |
"body": [ | |
"console.log('$1');", | |
"$2" | |
], | |
"description": "Log output to console" | |
} | |
*/ | |
"test case": { | |
"prefix": "test", | |
"body": [ | |
"func Test_$1(t *testing.T) {", | |
" testCases := []struct {", | |
" input string", | |
" output string", | |
" }{", | |
" {\"\",\"\"},", | |
" }", | |
"", | |
" for i, tc := range testCases {", | |
" t.Logf(\"test case %d\\n\", i)", | |
" if o := $1(tc.input); o != tc.output {", | |
" t.Fatalf(\"expected %s\\ngot\\n%s\\n\", tc.output, o)", | |
" }", | |
" }", | |
"}" | |
], | |
"description": "Create basic test suite case" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cmd
+shift
+p
-> Open User Snippet -> pick go, paste!