blob: b3acac1aded74108cc369d0fe0bf1076640ad62a (
plain)
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
|
# shorthand variable declaration
snippet v
${1} := ${2}
# variable initialization
snippet vr
var ${1:t} ${0:string}
# variable declaration
snippet var
var ${1} ${2} = ${3}
# variables declaration
snippet vars
var (
${1} ${2} = ${3}
)
# append
snippet ap
append(${1:slice}, ${0:value})
# bool
snippet bl
bool
# byte
snippet bt
byte
# break
snippet br
break
# channel
snippet ch
chan ${0:int}
# case
snippet cs
case ${1:value}:
${0}
# const
snippet c
const ${1:NAME} = ${0:0}
# constants with iota
snippet co
const (
${1:NAME1} = iota
${0:NAME2}
)
# continue
snippet cn
continue
# defer
snippet df
defer ${0:func}()
# defer recover
snippet dfr
defer func() {
if err := recover(); err != nil {
${0}
}
}()
# int
snippet i
int
# import
snippet im
import (
"${1:package}"
)
# interface
snippet in
interface{}
# full interface snippet
snippet inf
interface ${1:name} {
${2:/* methods */}
}
# if condition
snippet if
if ${1:/* condition */} {
${2}
}
snippet ife
if ${1:/* condition */} {
${2}
} else {
${0}
}
# else snippet
snippet el
else {
${1}
}
# error snippet
snippet ir
if err != nil {
return err
}
${0}
# false
snippet f
false
# fallthrough
snippet ft
fallthrough
# float
snippet fl
float32
# float32
snippet f3
float32
# float64
snippet f6
float64
# if else
snippet ie
if ${1:/* condition */} {
${2}
} else {
${3}
}
${0}
# for int loop
snippet for
for ${1}{
${0}
}
# for int loop
snippet fori
for ${2:i} := 0; $2 < ${1:count}; $2${3:++} {
${0}
}
# for range loop
snippet forr
for ${1:e} := range ${2:collection} {
${0}
}
# function simple
snippet fun
func ${1:funcName}(${2}) ${3:error} {
${4}
}
${0}
# function on receiver
snippet fum
func (${1:receiver} ${2:type}) ${3:funcName}(${4}) ${5:error} {
${6}
}
${0}
# log printf
snippet lf
log.Printf("%${1:s}", ${2:var})
# log printf
snippet lp
log.Println("${1}")
# make
snippet mk
make(${1:[]string}, ${0:0})
# map
snippet mp
map[${1:string}]${0:int}
# main()
snippet main
func main() {
${1}
}
${0}
# new
snippet nw
new(${0:type})
# package
snippet pa
package ${1:main}
# panic
snippet pn
panic("${0:msg}")
# print
snippet pr
fmt.Printf("%${1:s}\n", ${2:var})
# range
snippet rn
range ${0}
# return
snippet rt
return ${0}
# result
snippet rs
result
# select
snippet sl
select {
case ${1:v1} := <-${2:chan1}
${3}
default:
${0}
}
# string
snippet sr
string
# struct
snippet st
struct ${1:name} {
${2:/* data */}
}
${0}
# switch
snippet sw
switch ${1:var} {
case ${2:value1}:
${3}
case ${4:value2}:
${5}
default:
${0}
}
snippet sp
fmt.Sprintf("%${1:s}", ${2:var})
# true
snippet t
true
# goroutine named function
snippet g
go ${1:funcName}(${0})
# goroutine anonymous function
snippet ga
go func(${1} ${2:type}) {
${3:/* code */}
}(${0})
snippet test test function
func Test${1:name}(t *testing.T) {
${2}
}
${0}
snippet bench benchmark function
func Benchmark${1:name}(b *testing.B) {
for i := 0; i < b.N; i++ {
${2}
}
}
${0}
|