This repository was archived by the owner on Dec 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathlanguage-go.cson
140 lines (138 loc) · 3.91 KB
/
language-go.cson
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
'.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
}
"""