Skip to content

Instantly share code, notes, and snippets.

@spheromak
Created September 23, 2015 20:02
Show Gist options
  • Save spheromak/f2d4a4b1b3557a7596f2 to your computer and use it in GitHub Desktop.
Save spheromak/f2d4a4b1b3557a7596f2 to your computer and use it in GitHub Desktop.
snippet sic "some test snip"
Jesse Nelson <[email protected]>
endsnippet
snippet todo "TODO reminder" b
// TODO:(`echo $USER`) ${1:desc} `!v strftime("%c")`
endsnippet
snippet bug "Golang bug def" b
// BUG:(`echo $USER`) ${1:desc} `!v strftime("%c")`
endsnippet
# types and variables
snippet map "Map type" b
map[${1:keytype}]${2:valtype}
endsnippet
snippet : "Short variable declaration :=" !b
${1:name} := ${0:value}
endsnippet
snippet var "Variable declaration" b
var ${1:name}${2/(.+)/ /}${2:type}${3: = ${0:value}}
endsnippet
snippet vars "Variables declaration" b
var (
${1:name}${2/(.+)/ /}${2:type}${3: = ${0:value} }
)
endsnippet
snippet json "JSON field"
\`json:"${1:displayName}"\`
endsnippet
snippet er "Error clause " !b
if err != nil {
${0}
}
endsnippet
snippet errn "Error return " !b
if err != nil {
return err
}
${0}
endsnippet
snippet inerr "inline error" !b
if ${1} := ${2}; err != nil {
${3}
}
endsnippet
snippet ok "OK statement" !b
if !ok {
${0:${VISUAL}}
}
endsnippet
snippet gof "Anonymous Goroutine" !b
go func() {
${1}
}()
endsnippet
snippet def "Anonymous Defer" !b
defer func() {
${1}
}()
endsnippet
snippet ff "Fmt Printf debug" !b
fmt.Printf("${1} %+v\n", $1)
endsnippet
snippet fn "Fmt Println debug" !b
fmt.Println("${1}")
endsnippet
snippet lf "Log Printf debug" !b
log.Printf("${1} %+v\n", $1)
endsnippet
snippet ln "Log Println debug" !b
log.Println("${1}")
endsnippet
snippet make "make allocation" !b
make(${1:Type}, ${2:size})${0}
endsnippet
snippet test "test function" b
func Test${1:Function}(t *testing.T) {
${2}
}
endsnippet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment