123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- '.source.go':
- 'package clause':
- 'prefix': 'pkg'
- 'body': "package ${1:name}"
- 'single import':
- 'prefix': 'im'
- 'body': 'import "${1:package}"'
- 'multiple imports':
- 'prefix': 'ims'
- 'body': "import (\n\t\"${1:package}\"\n)"
- 'single constant':
- 'prefix': 'co'
- 'body': "const ${1:name} = ${2:value}"
- 'multiple constants':
- 'prefix': 'cos'
- 'body': "const (\n\t${1:name} = ${2:value}\n)"
- 'type interface declaration':
- 'prefix': 'tyi'
- 'body': "type ${1:name} interface {\n\t$0\n}"
- 'type struct declaration':
- 'prefix': 'tys'
- 'body': "type ${1:name} struct {\n\t$0\n}"
- 'type function declaration':
- 'prefix': 'tyf'
- 'body': 'type ${1:name} func(${2:commonParam}) ${3:returnParam}'
- 'main package':
- 'prefix': 'pkgm'
- 'body': "package main\n\nfunc main() {\n\t$0\n}"
- 'function declaration':
- 'prefix': 'func'
- 'body': "func $1($2) $3 {\n\t$0\n}"
- 'variable declaration':
- 'prefix': 'var'
- 'body': "var ${1:name} ${2:type}"
- 'switch statement':
- 'prefix': 'switch'
- 'body': "switch ${1:expression} {\ncase ${2:condition}:\n\t$0\n}"
- 'case clause':
- 'prefix': 'cs'
- 'body': "case ${1:condition}:$0"
- 'for statement':
- 'prefix': 'for'
- 'body': "for ${1:index} := 0; $1 < ${2:count}; $1${3:++} {\n\t$0\n}"
- 'for range statement':
- 'prefix': 'forr'
- 'body': "for ${1:var} := range ${2:var} {\n\t$0\n}"
- 'channel declaration':
- 'prefix': 'ch'
- 'body': "chan ${1:type}"
- 'map declaration':
- 'prefix': 'map'
- 'body': "map[${1:type}]${2:type}"
- 'empty interface':
- 'prefix': 'in'
- 'body': "interface{}"
- 'if statement':
- 'prefix': 'if'
- 'body': "if ${1:condition} {\n\t$0\n}"
- 'else branch':
- 'prefix': 'el'
- 'body': "else {\n\t$0\n}"
- 'if else statement':
- 'prefix': 'ie'
- 'body': "if ${1:condition} {\n\t$2\n} else {\n\t$0\n}"
- 'if err != nil':
- 'prefix': 'iferr'
- 'body': "if err != nil {\n\t${1:return}\n}"
- 'fmt.Println':
- 'prefix': 'fp'
- 'body': "fmt.Println(\"$1\")"
- 'fmt.Printf':
- 'prefix': 'ff'
- 'body': "fmt.Printf(\"$1\", ${2:var})"
- 'log.Println':
- 'prefix': 'lp'
- 'body': "log.Println(\"$1\")"
- 'log.Printf':
- 'prefix': 'lf'
- 'body': "log.Printf(\"$1\", ${2:var})"
- 'log variable content':
- 'prefix': 'lv'
- 'body': "log.Printf(\"${1:var}: %#+v\\\\n\", ${1:var})"
- 'make(...)':
- 'prefix': 'make'
- 'body': "make(${1:type}, ${2:0})"
- 'new(...)':
- 'prefix': 'new'
- 'body': "new(${1:type})"
- 'panic(...)':
- 'prefix': 'pn'
- 'body': "panic(\"$0\")"
- 'http ResponseWriter *Request':
- 'prefix': 'wr'
- 'body': "${1:w} http.ResponseWriter, ${2:r} *http.Request"
- 'http Context ResponseWriter *Request':
- 'prefix': 'cwr'
- 'body': "${1:c} context.Context, ${2:w} http.ResponseWriter, ${3:r} *http.Request"
- 'http.HandleFunc':
- 'prefix': 'hf'
- 'body': "${1:http}.HandleFunc(\"${2:/}\", ${3:handler})"
- 'http handler declaration':
- 'prefix': 'hand'
- 'body': "func $1(${2:w} http.ResponseWriter, ${3:r} *http.Request) {\n\t$0\n}"
- 'http.Redirect':
- 'prefix': 'rd'
- 'body': "http.Redirect(${1:w}, ${2:r}, \"${3:/}\", ${4:http.StatusFound})"
- 'http.Error':
- 'prefix': 'herr'
- 'body': "http.Error(${1:w}, ${2:err}.Error(), ${3:http.StatusInternalServerError})"
- 'http.ListenAndServe':
- 'prefix': 'las'
- 'body': "http.ListenAndServe(\"${1::8080}\", ${2:nil})"
- 'http.Serve':
- 'prefix': 'sv'
- 'body': "http.Serve(\"${1::8080}\", ${2:nil})"
- 'goroutine anonymous function':
- 'prefix': 'go'
- 'body': 'go func($1) {\n\t$2\n}($0)'
- 'goroutine function':
- 'prefix': 'gf'
- 'body': 'go ${1:func}($0)'
- 'defer statement':
- 'prefix': 'df'
- 'body': "defer ${1:func}($0)"
- 'test function':
- 'prefix': 'tf'
- 'body': "func Test$1(t *testing.T) {\n\t$0\n}"
- 'go template':
- 'prefix': 'got'
- 'body': """
- package ${1:main}
- import (
- "${2:fmt}"
- )
- func ${1:main}() {
- $3
- }
- """
|