Skip to content

Instantly share code, notes, and snippets.

@tophatsteve
Created March 6, 2017 08:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tophatsteve/cf5f8d69871d7d97c8456fb05112b91e to your computer and use it in GitHub Desktop.
Save tophatsteve/cf5f8d69871d7d97c8456fb05112b91e to your computer and use it in GitHub Desktop.
VS Code Go Snippets
{
"Read from Stdin": {
"prefix": "scan",
"body": [
"s := bufio.NewScanner(os.Stdin)",
"for s.Scan() {",
" $1",
"}"
],
"description": "Read from Stdin"
},
"Open file to read": {
"prefix": "file",
"body": [
"file, err := os.Open(\"$1\")",
"if err != nil {",
" log.Fatalln(err)",
"}",
"defer file.Close() "
],
"description": "Open file to read"
},
"Read file": {
"prefix": "read",
"body": [
"file, err := os.Open(\"$1\")",
"if err != nil {",
" log.Fatalln(err)",
"}",
"defer file.Close() ",
"",
"s := bufio.NewScanner(file)",
"for s.Scan() {",
" $1",
"}"
],
"description": "Open file and read lines"
},
"Not implement test" : {
"prefix": "test",
"body": [
"func Test$1(t *testing.T) {",
" assert.Equal(t, true, false, \"test not implemented\")",
"}"
],
"description": "Create an empty test"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment