This repository has been archived by the owner on Jul 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 646
/
go.json
254 lines (254 loc) · 7.61 KB
/
go.json
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
{
".source.go": {
"single import": {
"prefix": "im",
"body": "import \"${1:package}\"",
"description": "Snippet for import statement"
},
"multiple imports": {
"prefix": "ims",
"body": "import (\n\t\"${1:package}\"\n)",
"description": "Snippet for a import block"
},
"single constant": {
"prefix": "co",
"body": "const ${1:name} = ${2:value}",
"description": "Snippet for a constant"
},
"multiple constants": {
"prefix": "cos",
"body": "const (\n\t${1:name} = ${2:value}\n)",
"description": "Snippet for a constant block"
},
"type interface declaration": {
"prefix": "tyi",
"body": "type ${1:name} interface {\n\t$0\n}",
"description": "Snippet for a type interface"
},
"type struct declaration": {
"prefix": "tys",
"body": "type ${1:name} struct {\n\t$0\n}",
"description": "Snippet for a struct declaration"
},
"package main and main function": {
"prefix": "pkgm",
"body": "package main\n\nfunc main() {\n\t$0\n}",
"description": "Snippet for main package & function"
},
"function declaration": {
"prefix": "func",
"body": "func $1($2) $3 {\n\t$0\n}",
"description": "Snippet for function declaration"
},
"variable declaration": {
"prefix": "var",
"body": "var ${1:name} ${2:type}",
"description": "Snippet for a variable"
},
"switch statement": {
"prefix": "switch",
"body": "switch ${1:expression} {\ncase ${2:condition}:\n\t$0\n}",
"description": "Snippet for switch statement"
},
"select statement": {
"prefix": "sel",
"body": "select {\ncase ${1:condition}:\n\t$0\n}",
"description": "Snippet for select statement"
},
"case clause": {
"prefix": "cs",
"body": "case ${1:condition}:$0",
"description": "Snippet for case clause"
},
"for statement": {
"prefix": "for",
"body": "for ${1:index} := 0; $1 < ${2:count}; $1${3:++} {\n\t$0\n}",
"description": "Snippet for a for loop"
},
"for range statement": {
"prefix": "forr",
"body": "for ${1:_, }${2:var} := range ${3:var} {\n\t$0\n}",
"description": "Snippet for a for range loop"
},
"channel declaration": {
"prefix": "ch",
"body": "chan ${1:type}",
"description": "Snippet for a channel"
},
"map declaration": {
"prefix": "map",
"body": "map[${1:type}]${2:type}",
"description": "Snippet for a map"
},
"empty interface": {
"prefix": "in",
"body": "interface{}",
"description": "Snippet for empty interface"
},
"if statement": {
"prefix": "if",
"body": "if ${1:condition} {\n\t$0\n}",
"description": "Snippet for if statement"
},
"else branch": {
"prefix": "el",
"body": "else {\n\t$0\n}",
"description": "Snippet for else branch"
},
"if else statement": {
"prefix": "ie",
"body": "if ${1:condition} {\n\t$2\n} else {\n\t$0\n}",
"description": "Snippet for if else"
},
"if err != nil": {
"prefix": "iferr",
"body": "if err != nil {\n\t${1:return ${2:nil, }${3:err}}\n}",
"description": "Snippet for if err != nil"
},
"fmt.Println": {
"prefix": "fp",
"body": "fmt.Println(\"$1\")",
"description": "Snippet for fmt.Println()"
},
"fmt.Printf": {
"prefix": "ff",
"body": "fmt.Printf(\"$1\", ${2:var})",
"description": "Snippet for fmt.Printf()"
},
"log.Println": {
"prefix": "lp",
"body": "log.Println(\"$1\")",
"description": "Snippet for log.Println()"
},
"log.Printf": {
"prefix": "lf",
"body": "log.Printf(\"$1\", ${2:var})",
"description": "Snippet for log.Printf()"
},
"log variable content": {
"prefix": "lv",
"body": "log.Printf(\"${1:var}: %#+v\\\\n\", ${1:var})",
"description": "Snippet for log.Printf() with variable content"
},
"t.Log": {
"prefix": "tl",
"body": "t.Log(\"$1\")",
"description": "Snippet for t.Log()"
},
"t.Logf": {
"prefix": "tlf",
"body": "t.Logf(\"$1\", ${2:var})",
"description": "Snippet for t.Logf()"
},
"t.Logf variable content": {
"prefix": "tlv",
"body": "t.Logf(\"${1:var}: %#+v\\\\n\", ${1:var})",
"description": "Snippet for t.Logf() with variable content"
},
"make(...)": {
"prefix": "make",
"body": "make(${1:type}, ${2:0})",
"description": "Snippet for make statement"
},
"new(...)": {
"prefix": "new",
"body": "new(${1:type})",
"description": "Snippet for new statement"
},
"panic(...)": {
"prefix": "pn",
"body": "panic(\"$0\")",
"description": "Snippet for panic"
},
"http ResponseWriter *Request": {
"prefix": "wr",
"body": "${1:w} http.ResponseWriter, ${2:r} *http.Request",
"description": "Snippet for http Response"
},
"http.HandleFunc": {
"prefix": "hf",
"body": "${1:http}.HandleFunc(\"${2:/}\", ${3:handler})",
"description": "Snippet for http.HandleFunc()"
},
"http handler declaration": {
"prefix": "hand",
"body": "func $1(${2:w} http.ResponseWriter, ${3:r} *http.Request) {\n\t$0\n}",
"description": "Snippet for http handler declaration"
},
"http.Redirect": {
"prefix": "rd",
"body": "http.Redirect(${1:w}, ${2:r}, \"${3:/}\", ${4:http.StatusFound})",
"description": "Snippet for http.Redirect()"
},
"http.Error": {
"prefix": "herr",
"body": "http.Error(${1:w}, ${2:err}.Error(), ${3:http.StatusInternalServerError})",
"description": "Snippet for http.Error()"
},
"http.ListenAndServe": {
"prefix": "las",
"body": "http.ListenAndServe(\"${1::8080}\", ${2:nil})",
"description": "Snippet for http.ListenAndServe"
},
"http.Serve": {
"prefix": "sv",
"body": "http.Serve(\"${1::8080}\", ${2:nil})",
"description": "Snippet for http.Serve"
},
"goroutine anonymous function": {
"prefix": "go",
"body": "go func($1) {\n\t$2\n}($0)",
"description": "Snippet for anonymous goroutine declaration"
},
"goroutine function": {
"prefix": "gf",
"body": "go ${1:func}($0)",
"description": "Snippet for goroutine declaration"
},
"defer statement": {
"prefix": "df",
"body": "defer ${1:func}($0)",
"description": "Snippet for defer statement"
},
"test function": {
"prefix": "tf",
"body": "func Test$1(t *testing.T) {\n\t$0\n}",
"description": "Snippet for Test function"
},
"benchmark function": {
"prefix": "bf",
"body": "func Benchmark$1(b *testing.B) {\n\tfor ${2:i} := 0; ${2:i} < b.N; ${2:i}++ {\n\t\t$0\n\t}\n}",
"description": "Snippet for Benchmark function"
},
"example function": {
"prefix": "ef",
"body": "func Example$1() {\n\t$2\n\t//Output:\n\t$3\n}",
"description": "Snippet for Example function"
},
"table driven test": {
"prefix": "tdt",
"body": "func Test$1(t *testing.T) {\n\ttestCases := []struct {\n\t\tdesc\tstring\n\t\t$2\n\t}{\n\t\t{\n\t\t\tdesc: \"$3\",\n\t\t\t$4\n\t\t},\n\t}\n\tfor _, tC := range testCases {\n\t\tt.Run(tC.desc, func(t *testing.T) {\n\t\t\t$0\n\t\t})\n\t}\n}",
"description": "Snippet for table driven test"
},
"init function": {
"prefix": "finit",
"body": "func init() {\n\t$1\n}",
"description": "Snippet for init function"
},
"main function": {
"prefix": "fmain",
"body": "func main() {\n\t$1\n}",
"description": "Snippet for main function"
},
"method declaration": {
"prefix": "meth",
"body": "func (${1:receiver} ${2:type}) ${3:method}($4) $5 {\n\t$0\n}",
"description": "Snippet for method declaration"
},
"hello world web app": {
"prefix": "helloweb",
"body": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"time\"\n)\n\nfunc greet(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprintf(w, \"Hello World! %s\", time.Now())\n}\n\nfunc main() {\n\thttp.HandleFunc(\"/\", greet)\n\thttp.ListenAndServe(\":8080\", nil)\n}",
"description": "Snippet for sample hello world webapp"
}
}
}