Skip to content

Commit

Permalink
Add snippets for go.snip
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewstuart committed Feb 16, 2015
1 parent 2bbedd9 commit 57b57b0
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions gosnippets/snippets/go.snip
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ abbr fn := func() { ... }
snippet ap
abbr append(slice, value)
append(${1:slice}, ${0:value})
# append assign
snippet ap=
abbr slice = append(slice, value)
${1:slice} = append($1, ${0:value})
# break
snippet br
abbr break
Expand Down Expand Up @@ -262,6 +266,28 @@ abbr func TestXYZ(t *testing.T) { ... }
func Test${1:Function}(t *testing.T) {
${0}
}
# test server
snippet tsrv
abbr ts := httptest.NewServer(...)
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, ${1:`response`})
}))
defer ts.Close()

//Use testing server url (type string) somewhere
${0:someUrl} = ts.URL
# test error
snippet ter
abbr if err != nil { t.Errorf(...) }
if err != nil {
t.Errorf("${1}")
}
# test fatal error
snippet terf
abbr if err != nil { t.Fatalf(...) }
if err != nil {
t.Fatalf("${1}")
}
# variable declaration
snippet var
abbr var x Type [= ...]
Expand Down

0 comments on commit 57b57b0

Please sign in to comment.