@enjoys/context-engine 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/data/commands/adb.json +322 -0
- package/data/commands/alembic.json +301 -0
- package/data/commands/artisan.json +277 -0
- package/data/commands/atlas.json +426 -0
- package/data/commands/auth0.json +648 -0
- package/data/commands/bat.json +84 -0
- package/data/commands/bundle.json +321 -0
- package/data/commands/composer.json +507 -0
- package/data/commands/dart.json +216 -0
- package/data/commands/dbmate.json +257 -0
- package/data/commands/docker-compose.json +384 -0
- package/data/commands/drizzle-kit.json +217 -0
- package/data/commands/expo.json +65 -0
- package/data/commands/fastlane.json +243 -0
- package/data/commands/fd.json +86 -0
- package/data/commands/flutter.json +298 -0
- package/data/commands/flyway.json +261 -0
- package/data/commands/fzf.json +103 -0
- package/data/commands/gem.json +267 -0
- package/data/commands/jq.json +100 -0
- package/data/commands/k9s.json +62 -0
- package/data/commands/liquibase.json +399 -0
- package/data/commands/manifest.json +619 -0
- package/data/commands/minikube.json +60 -0
- package/data/commands/ng.json +64 -0
- package/data/commands/nuxt.json +60 -0
- package/data/commands/php.json +157 -0
- package/data/commands/pm2.json +259 -0
- package/data/commands/pod.json +175 -0
- package/data/commands/prisma.json +257 -0
- package/data/commands/rails.json +372 -0
- package/data/commands/rake.json +360 -0
- package/data/commands/react-native.json +57 -0
- package/data/commands/rg.json +103 -0
- package/data/commands/rspec.json +257 -0
- package/data/commands/ruby.json +108 -0
- package/data/commands/sequelize.json +342 -0
- package/data/commands/snyk.json +442 -0
- package/data/commands/sonar-scanner.json +219 -0
- package/data/commands/stripe.json +314 -0
- package/data/commands/symfony.json +449 -0
- package/data/commands/tmux.json +197 -0
- package/data/commands/trivy.json +367 -0
- package/data/commands/twilio.json +382 -0
- package/data/commands/typeorm.json +262 -0
- package/data/commands/vue.json +60 -0
- package/data/commands/wp.json +857 -0
- package/data/commands/xcodebuild.json +141 -0
- package/data/commands/yq.json +57 -0
- package/data/completion/bash.json +1184 -0
- package/data/completion/c.json +1067 -0
- package/data/completion/cpp.json +824 -0
- package/data/completion/csharp.json +860 -0
- package/data/completion/dockerfile.json +536 -0
- package/data/completion/go.json +1346 -0
- package/data/completion/html.json +806 -0
- package/data/completion/java.json +1112 -0
- package/data/completion/javascript.json +914 -0
- package/data/completion/lua.json +968 -0
- package/data/completion/php.json +1535 -0
- package/data/completion/python.json +1427 -0
- package/data/completion/ruby.json +1531 -0
- package/data/completion/rust.json +698 -0
- package/data/completion/sql.json +887 -0
- package/data/completion/toml.json +428 -0
- package/data/completion/typescript.json +338 -0
- package/data/completion/yaml.json +563 -0
- package/data/defination/bash.json +565 -0
- package/data/defination/c.json +865 -0
- package/data/defination/cpp.json +348 -0
- package/data/defination/csharp.json +144 -0
- package/data/defination/dockerfile.json +113 -0
- package/data/defination/go.json +561 -0
- package/data/defination/html.json +559 -0
- package/data/defination/java.json +184 -0
- package/data/defination/javascript.json +265 -0
- package/data/defination/lua.json +181 -0
- package/data/defination/php.json +726 -0
- package/data/defination/python.json +717 -0
- package/data/defination/ruby.json +670 -0
- package/data/defination/rust.json +207 -0
- package/data/defination/sql.json +473 -0
- package/data/defination/toml.json +251 -0
- package/data/defination/typescript.json +29 -0
- package/data/defination/yaml.json +197 -0
- package/data/hover/bash.json +245 -0
- package/data/hover/c.json +265 -0
- package/data/hover/cpp.json +210 -0
- package/data/hover/csharp.json +290 -0
- package/data/hover/dockerfile.json +145 -0
- package/data/hover/go.json +580 -0
- package/data/hover/html.json +250 -0
- package/data/hover/java.json +395 -0
- package/data/hover/javascript.json +330 -0
- package/data/hover/lua.json +265 -0
- package/data/hover/php.json +300 -0
- package/data/hover/python.json +380 -0
- package/data/hover/ruby.json +265 -0
- package/data/hover/rust.json +275 -0
- package/data/hover/sql.json +230 -0
- package/data/hover/toml.json +145 -0
- package/data/hover/typescript.json +120 -0
- package/data/hover/yaml.json +165 -0
- package/data/manifest.json +242 -0
- package/package.json +1 -1
|
@@ -0,0 +1,1346 @@
|
|
|
1
|
+
{
|
|
2
|
+
"language": "go",
|
|
3
|
+
"completions": [
|
|
4
|
+
{
|
|
5
|
+
"label": "fmt.Println",
|
|
6
|
+
"kind": 1,
|
|
7
|
+
"detail": "Print line to stdout",
|
|
8
|
+
"documentation": { "value": "Formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended.\n\n```go\nfmt.Println(\"Hello, world!\")\nfmt.Println(\"x =\", x)\nfmt.Println(a, b, c)\n```" },
|
|
9
|
+
"insertText": "fmt.Println(${1:a})",
|
|
10
|
+
"insertTextRules": 4,
|
|
11
|
+
"sortText": "00_fmt_println"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"label": "fmt.Printf",
|
|
15
|
+
"kind": 1,
|
|
16
|
+
"detail": "Formatted print to stdout",
|
|
17
|
+
"documentation": { "value": "Formats according to a format specifier and writes to standard output.\n\n```go\nfmt.Printf(\"Name: %s, Age: %d\\n\", name, age)\nfmt.Printf(\"%v\\n\", myStruct)\nfmt.Printf(\"%#v\\n\", obj) // Go-syntax representation\n```" },
|
|
18
|
+
"insertText": "fmt.Printf(\"${1:%v}\\n\", ${2:a})",
|
|
19
|
+
"insertTextRules": 4,
|
|
20
|
+
"sortText": "00_fmt_printf"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"label": "fmt.Sprintf",
|
|
24
|
+
"kind": 1,
|
|
25
|
+
"detail": "Format string and return it",
|
|
26
|
+
"documentation": { "value": "Formats according to a format specifier and returns the resulting string.\n\n```go\ns := fmt.Sprintf(\"Hello, %s!\", name)\nmsg := fmt.Sprintf(\"%d items found\", count)\naddr := fmt.Sprintf(\"%s:%d\", host, port)\n```" },
|
|
27
|
+
"insertText": "fmt.Sprintf(\"${1:%v}\", ${2:a})",
|
|
28
|
+
"insertTextRules": 4,
|
|
29
|
+
"sortText": "00_fmt_sprintf"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"label": "fmt.Fprintf",
|
|
33
|
+
"kind": 1,
|
|
34
|
+
"detail": "Formatted print to writer",
|
|
35
|
+
"documentation": { "value": "Formats according to a format specifier and writes to w.\n\n```go\nfmt.Fprintf(os.Stderr, \"Error: %v\\n\", err)\nfmt.Fprintf(w, \"Hello, %s!\", name)\n```" },
|
|
36
|
+
"insertText": "fmt.Fprintf(${1:w}, \"${2:%v}\\n\", ${3:a})",
|
|
37
|
+
"insertTextRules": 4,
|
|
38
|
+
"sortText": "00_fmt_fprintf"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"label": "fmt.Errorf",
|
|
42
|
+
"kind": 1,
|
|
43
|
+
"detail": "Format and return an error",
|
|
44
|
+
"documentation": { "value": "Formats according to a format specifier and returns an error. Use `%w` to wrap an error.\n\n```go\nerr := fmt.Errorf(\"failed to open %s: %w\", filename, err)\nreturn fmt.Errorf(\"invalid input: %s\", input)\n```" },
|
|
45
|
+
"insertText": "fmt.Errorf(\"${1:failed to %s: %w}\", ${2:args})",
|
|
46
|
+
"insertTextRules": 4,
|
|
47
|
+
"sortText": "00_fmt_errorf"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"label": "fmt.Sscanf",
|
|
51
|
+
"kind": 1,
|
|
52
|
+
"detail": "Scan formatted string",
|
|
53
|
+
"documentation": { "value": "Scans the argument string, storing successive space-separated values into successive arguments as determined by the format.\n\n```go\nvar name string\nvar age int\nfmt.Sscanf(\"Alice 30\", \"%s %d\", &name, &age)\n```" },
|
|
54
|
+
"insertText": "fmt.Sscanf(${1:str}, \"${2:%s}\", ${3:&val})",
|
|
55
|
+
"insertTextRules": 4,
|
|
56
|
+
"sortText": "00_fmt_sscanf"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"label": "fmt.Stringer",
|
|
60
|
+
"kind": 7,
|
|
61
|
+
"detail": "Stringer interface (String() string)",
|
|
62
|
+
"documentation": { "value": "The `Stringer` interface is defined by `fmt`. Any type that implements `String() string` will be used by `fmt` functions for formatting.\n\n```go\ntype Stringer interface {\n String() string\n}\n\nfunc (p Person) String() string {\n return fmt.Sprintf(\"%s (%d)\", p.Name, p.Age)\n}\n```" },
|
|
63
|
+
"insertText": "func (${1:t} ${2:Type}) String() string {\n\treturn fmt.Sprintf(\"${3:%v}\", ${4:t})\n}",
|
|
64
|
+
"insertTextRules": 4,
|
|
65
|
+
"sortText": "01_fmt_stringer"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"label": "make",
|
|
69
|
+
"kind": 1,
|
|
70
|
+
"detail": "Allocate and initialize slice, map, or channel",
|
|
71
|
+
"documentation": { "value": "Built-in function that allocates and initializes slices, maps, or channels.\n\n```go\ns := make([]int, 0, 10) // slice with len=0, cap=10\nm := make(map[string]int) // map\nch := make(chan int, 5) // buffered channel\n```" },
|
|
72
|
+
"insertText": "make(${1:[]Type}, ${2:0})",
|
|
73
|
+
"insertTextRules": 4,
|
|
74
|
+
"sortText": "00_make"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"label": "new",
|
|
78
|
+
"kind": 1,
|
|
79
|
+
"detail": "Allocate memory for a type",
|
|
80
|
+
"documentation": { "value": "Built-in function that allocates memory for a type and returns a pointer to it. The memory is zero-initialized.\n\n```go\np := new(int) // *int, points to 0\ns := new(MyStruct) // *MyStruct, zero value\n```" },
|
|
81
|
+
"insertText": "new(${1:Type})",
|
|
82
|
+
"insertTextRules": 4,
|
|
83
|
+
"sortText": "00_new"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"label": "append",
|
|
87
|
+
"kind": 1,
|
|
88
|
+
"detail": "Append elements to a slice",
|
|
89
|
+
"documentation": { "value": "Built-in function that appends elements to the end of a slice. If the backing array is too small, a new one is allocated.\n\n```go\ns = append(s, 1, 2, 3)\ns = append(s, other...) // append another slice\ns = append(s, elem)\n```" },
|
|
90
|
+
"insertText": "append(${1:slice}, ${2:elems})",
|
|
91
|
+
"insertTextRules": 4,
|
|
92
|
+
"sortText": "00_append"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"label": "copy",
|
|
96
|
+
"kind": 1,
|
|
97
|
+
"detail": "Copy elements between slices",
|
|
98
|
+
"documentation": { "value": "Built-in function that copies elements from a source slice into a destination slice. Returns the number of elements copied.\n\n```go\nn := copy(dst, src)\ncopy(dst[1:], src[2:5])\n```" },
|
|
99
|
+
"insertText": "copy(${1:dst}, ${2:src})",
|
|
100
|
+
"insertTextRules": 4,
|
|
101
|
+
"sortText": "00_copy"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"label": "delete",
|
|
105
|
+
"kind": 1,
|
|
106
|
+
"detail": "Delete a key from a map",
|
|
107
|
+
"documentation": { "value": "Built-in function that deletes the element with the specified key from the map. No-op if the key is not present.\n\n```go\ndelete(m, \"key\")\ndelete(userMap, userID)\n```" },
|
|
108
|
+
"insertText": "delete(${1:m}, ${2:key})",
|
|
109
|
+
"insertTextRules": 4,
|
|
110
|
+
"sortText": "00_delete"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"label": "len",
|
|
114
|
+
"kind": 1,
|
|
115
|
+
"detail": "Return the length",
|
|
116
|
+
"documentation": { "value": "Built-in function that returns the length of a value: number of elements in an array, slice, string, map, or channel buffer.\n\n```go\nn := len(mySlice)\nif len(s) == 0 { /* empty */ }\nfor i := 0; i < len(arr); i++ { }\n```" },
|
|
117
|
+
"insertText": "len(${1:v})",
|
|
118
|
+
"insertTextRules": 4,
|
|
119
|
+
"sortText": "00_len"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"label": "cap",
|
|
123
|
+
"kind": 1,
|
|
124
|
+
"detail": "Return the capacity",
|
|
125
|
+
"documentation": { "value": "Built-in function that returns the capacity of a slice, array, or channel buffer.\n\n```go\nc := cap(mySlice)\nif len(s) == cap(s) { /* slice is full */ }\n```" },
|
|
126
|
+
"insertText": "cap(${1:v})",
|
|
127
|
+
"insertTextRules": 4,
|
|
128
|
+
"sortText": "00_cap"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"label": "close",
|
|
132
|
+
"kind": 1,
|
|
133
|
+
"detail": "Close a channel",
|
|
134
|
+
"documentation": { "value": "Built-in function that closes a channel. Only the sender should close a channel.\n\n```go\nclose(ch)\n\n// Receiving from closed channel:\nv, ok := <-ch // ok is false when channel is closed\n```" },
|
|
135
|
+
"insertText": "close(${1:ch})",
|
|
136
|
+
"insertTextRules": 4,
|
|
137
|
+
"sortText": "00_close"
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"label": "panic",
|
|
141
|
+
"kind": 1,
|
|
142
|
+
"detail": "Stop normal execution",
|
|
143
|
+
"documentation": { "value": "Built-in function that stops normal execution of the current goroutine. Deferred functions are still run.\n\n```go\npanic(\"unreachable\")\npanic(fmt.Sprintf(\"unexpected type: %T\", v))\n```" },
|
|
144
|
+
"insertText": "panic(${1:\"error message\"})",
|
|
145
|
+
"insertTextRules": 4,
|
|
146
|
+
"sortText": "00_panic"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"label": "recover",
|
|
150
|
+
"kind": 1,
|
|
151
|
+
"detail": "Regain control after a panic",
|
|
152
|
+
"documentation": { "value": "Built-in function that regains control of a panicking goroutine. Only useful inside deferred functions.\n\n```go\ndefer func() {\n if r := recover(); r != nil {\n log.Println(\"Recovered:\", r)\n }\n}()\n```" },
|
|
153
|
+
"insertText": "recover()",
|
|
154
|
+
"insertTextRules": 4,
|
|
155
|
+
"sortText": "00_recover"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"label": "complex",
|
|
159
|
+
"kind": 1,
|
|
160
|
+
"detail": "Construct a complex number",
|
|
161
|
+
"documentation": { "value": "Built-in function that constructs a complex value from two floating-point values.\n\n```go\nc := complex(1.0, 2.0) // 1+2i\n```" },
|
|
162
|
+
"insertText": "complex(${1:real}, ${2:imag})",
|
|
163
|
+
"insertTextRules": 4,
|
|
164
|
+
"sortText": "01_complex"
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"label": "real",
|
|
168
|
+
"kind": 1,
|
|
169
|
+
"detail": "Extract real part of complex number",
|
|
170
|
+
"documentation": { "value": "Built-in function that returns the real part of a complex number.\n\n```go\nr := real(c) // float64\n```" },
|
|
171
|
+
"insertText": "real(${1:c})",
|
|
172
|
+
"insertTextRules": 4,
|
|
173
|
+
"sortText": "01_real"
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
"label": "imag",
|
|
177
|
+
"kind": 1,
|
|
178
|
+
"detail": "Extract imaginary part of complex number",
|
|
179
|
+
"documentation": { "value": "Built-in function that returns the imaginary part of a complex number.\n\n```go\ni := imag(c) // float64\n```" },
|
|
180
|
+
"insertText": "imag(${1:c})",
|
|
181
|
+
"insertTextRules": 4,
|
|
182
|
+
"sortText": "01_imag"
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"label": "clear",
|
|
186
|
+
"kind": 1,
|
|
187
|
+
"detail": "Clear a map or zero a slice (Go 1.21+)",
|
|
188
|
+
"documentation": { "value": "Built-in function (Go 1.21+) that deletes all entries from a map or zeroes all elements of a slice.\n\n```go\nclear(m) // delete all map entries\nclear(s) // zero all slice elements, keep length\n```" },
|
|
189
|
+
"insertText": "clear(${1:v})",
|
|
190
|
+
"insertTextRules": 4,
|
|
191
|
+
"sortText": "00_clear"
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
"label": "min",
|
|
195
|
+
"kind": 1,
|
|
196
|
+
"detail": "Return the minimum value (Go 1.21+)",
|
|
197
|
+
"documentation": { "value": "Built-in function (Go 1.21+) that returns the smallest of its arguments.\n\n```go\nm := min(a, b)\nsmallest := min(x, y, z)\n```" },
|
|
198
|
+
"insertText": "min(${1:a}, ${2:b})",
|
|
199
|
+
"insertTextRules": 4,
|
|
200
|
+
"sortText": "00_min"
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"label": "max",
|
|
204
|
+
"kind": 1,
|
|
205
|
+
"detail": "Return the maximum value (Go 1.21+)",
|
|
206
|
+
"documentation": { "value": "Built-in function (Go 1.21+) that returns the largest of its arguments.\n\n```go\nm := max(a, b)\nlargest := max(x, y, z)\n```" },
|
|
207
|
+
"insertText": "max(${1:a}, ${2:b})",
|
|
208
|
+
"insertTextRules": 4,
|
|
209
|
+
"sortText": "00_max"
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
"label": "print",
|
|
213
|
+
"kind": 1,
|
|
214
|
+
"detail": "Built-in print (not for production)",
|
|
215
|
+
"documentation": { "value": "Built-in function that formats arguments in an implementation-specific way and writes to stderr. Useful for bootstrapping and debugging; use `fmt.Print` for production.\n\n```go\nprint(\"debug: \", x, \"\\n\")\n```" },
|
|
216
|
+
"insertText": "print(${1:args})",
|
|
217
|
+
"insertTextRules": 4,
|
|
218
|
+
"sortText": "02_print"
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
"label": "println",
|
|
222
|
+
"kind": 1,
|
|
223
|
+
"detail": "Built-in println (not for production)",
|
|
224
|
+
"documentation": { "value": "Built-in function that formats arguments and writes to stderr with spaces and a newline. Use `fmt.Println` for production code.\n\n```go\nprintln(\"debug:\", x)\n```" },
|
|
225
|
+
"insertText": "println(${1:args})",
|
|
226
|
+
"insertTextRules": 4,
|
|
227
|
+
"sortText": "02_println"
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
"label": "string",
|
|
231
|
+
"kind": 14,
|
|
232
|
+
"detail": "String type",
|
|
233
|
+
"documentation": { "value": "The `string` type represents an immutable sequence of bytes, conventionally holding UTF-8 text.\n\n```go\nvar s string = \"hello\"\nbs := []byte(s)\nrs := []rune(s)\n```" },
|
|
234
|
+
"insertText": "string",
|
|
235
|
+
"insertTextRules": 0,
|
|
236
|
+
"sortText": "01_string"
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
"label": "int",
|
|
240
|
+
"kind": 14,
|
|
241
|
+
"detail": "Signed integer type",
|
|
242
|
+
"documentation": { "value": "The `int` type is a platform-dependent signed integer (32 or 64 bits).\n\n```go\nvar x int = 42\nvar y int = -1\n```" },
|
|
243
|
+
"insertText": "int",
|
|
244
|
+
"insertTextRules": 0,
|
|
245
|
+
"sortText": "01_int"
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
"label": "float64",
|
|
249
|
+
"kind": 14,
|
|
250
|
+
"detail": "64-bit floating-point type",
|
|
251
|
+
"documentation": { "value": "The `float64` type is an IEEE-754 64-bit floating-point number.\n\n```go\nvar f float64 = 3.14\nvar g float64 = 1.0e10\n```" },
|
|
252
|
+
"insertText": "float64",
|
|
253
|
+
"insertTextRules": 0,
|
|
254
|
+
"sortText": "01_float64"
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
"label": "bool",
|
|
258
|
+
"kind": 14,
|
|
259
|
+
"detail": "Boolean type",
|
|
260
|
+
"documentation": { "value": "The `bool` type represents boolean values: `true` or `false`.\n\n```go\nvar ok bool = true\nif ok { }\n```" },
|
|
261
|
+
"insertText": "bool",
|
|
262
|
+
"insertTextRules": 0,
|
|
263
|
+
"sortText": "01_bool"
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
"label": "byte",
|
|
267
|
+
"kind": 14,
|
|
268
|
+
"detail": "Alias for uint8",
|
|
269
|
+
"documentation": { "value": "`byte` is an alias for `uint8`. Used for raw data and ASCII characters.\n\n```go\nvar b byte = 'A'\ndata := []byte(\"hello\")\n```" },
|
|
270
|
+
"insertText": "byte",
|
|
271
|
+
"insertTextRules": 0,
|
|
272
|
+
"sortText": "01_byte"
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
"label": "rune",
|
|
276
|
+
"kind": 14,
|
|
277
|
+
"detail": "Alias for int32 (Unicode code point)",
|
|
278
|
+
"documentation": { "value": "`rune` is an alias for `int32`. Represents a Unicode code point.\n\n```go\nvar r rune = '世'\nfor _, r := range \"Hello, 世界\" {\n fmt.Printf(\"%c\", r)\n}\n```" },
|
|
279
|
+
"insertText": "rune",
|
|
280
|
+
"insertTextRules": 0,
|
|
281
|
+
"sortText": "01_rune"
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
"label": "error",
|
|
285
|
+
"kind": 7,
|
|
286
|
+
"detail": "Built-in error interface",
|
|
287
|
+
"documentation": { "value": "The `error` interface is the conventional interface for representing an error condition.\n\n```go\ntype error interface {\n Error() string\n}\n\nif err != nil {\n return err\n}\n```" },
|
|
288
|
+
"insertText": "error",
|
|
289
|
+
"insertTextRules": 0,
|
|
290
|
+
"sortText": "01_error"
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
"label": "any",
|
|
294
|
+
"kind": 14,
|
|
295
|
+
"detail": "Alias for interface{} (Go 1.18+)",
|
|
296
|
+
"documentation": { "value": "`any` is an alias for `interface{}`. It can hold a value of any type.\n\n```go\nvar v any = 42\nv = \"hello\"\n```" },
|
|
297
|
+
"insertText": "any",
|
|
298
|
+
"insertTextRules": 0,
|
|
299
|
+
"sortText": "01_any"
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
"label": "comparable",
|
|
303
|
+
"kind": 7,
|
|
304
|
+
"detail": "Comparable constraint (Go 1.18+)",
|
|
305
|
+
"documentation": { "value": "`comparable` is the constraint for types that support `==` and `!=`. Used as a type constraint in generics.\n\n```go\nfunc Contains[T comparable](s []T, v T) bool {\n for _, item := range s {\n if item == v { return true }\n }\n return false\n}\n```" },
|
|
306
|
+
"insertText": "comparable",
|
|
307
|
+
"insertTextRules": 0,
|
|
308
|
+
"sortText": "01_comparable"
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
"label": "func",
|
|
312
|
+
"kind": 14,
|
|
313
|
+
"detail": "Function declaration",
|
|
314
|
+
"documentation": { "value": "Declare a new function.\n\n```go\nfunc name(params) returnType {\n // body\n}\n```" },
|
|
315
|
+
"insertText": "func ${1:name}(${2:params}) ${3:returnType} {\n\t${0}\n}",
|
|
316
|
+
"insertTextRules": 4,
|
|
317
|
+
"sortText": "00_func"
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
"label": "method",
|
|
321
|
+
"kind": 14,
|
|
322
|
+
"detail": "Method declaration",
|
|
323
|
+
"documentation": { "value": "Declare a method on a type.\n\n```go\nfunc (t *Type) Method(params) returnType {\n // body\n}\n```" },
|
|
324
|
+
"insertText": "func (${1:t} *${2:Type}) ${3:Method}(${4:params}) ${5:returnType} {\n\t${0}\n}",
|
|
325
|
+
"insertTextRules": 4,
|
|
326
|
+
"sortText": "00_method"
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
"label": "goroutine",
|
|
330
|
+
"kind": 14,
|
|
331
|
+
"detail": "Launch a goroutine",
|
|
332
|
+
"documentation": { "value": "Start a new goroutine with an anonymous function.\n\n```go\ngo func() {\n // concurrent work\n}()\n```" },
|
|
333
|
+
"insertText": "go func() {\n\t${0}\n}()",
|
|
334
|
+
"insertTextRules": 4,
|
|
335
|
+
"sortText": "00_goroutine"
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
"label": "channel send/receive",
|
|
339
|
+
"kind": 14,
|
|
340
|
+
"detail": "Channel operations",
|
|
341
|
+
"documentation": { "value": "Send and receive on channels.\n\n```go\nch <- value // send\nv := <-ch // receive\nv, ok := <-ch // receive with close check\n```" },
|
|
342
|
+
"insertText": "${1:ch} <- ${2:value}",
|
|
343
|
+
"insertTextRules": 4,
|
|
344
|
+
"sortText": "00_channel"
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
"label": "select",
|
|
348
|
+
"kind": 14,
|
|
349
|
+
"detail": "Select statement for channels",
|
|
350
|
+
"documentation": { "value": "A `select` statement lets a goroutine wait on multiple channel operations.\n\n```go\nselect {\ncase v := <-ch1:\n fmt.Println(v)\ncase ch2 <- val:\n // sent\ndefault:\n // no channel is ready\n}\n```" },
|
|
351
|
+
"insertText": "select {\ncase ${1:v} := <-${2:ch1}:\n\t${3}\ncase ${4:ch2} <- ${5:val}:\n\t${6}\ndefault:\n\t${0}\n}",
|
|
352
|
+
"insertTextRules": 4,
|
|
353
|
+
"sortText": "00_select"
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
"label": "switch",
|
|
357
|
+
"kind": 14,
|
|
358
|
+
"detail": "Switch statement",
|
|
359
|
+
"documentation": { "value": "Multi-way branch. No fallthrough by default in Go.\n\n```go\nswitch v {\ncase 1:\n // ...\ncase 2:\n // ...\ndefault:\n // ...\n}\n```" },
|
|
360
|
+
"insertText": "switch ${1:v} {\ncase ${2:value}:\n\t${3}\ndefault:\n\t${0}\n}",
|
|
361
|
+
"insertTextRules": 4,
|
|
362
|
+
"sortText": "00_switch"
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
"label": "type switch",
|
|
366
|
+
"kind": 14,
|
|
367
|
+
"detail": "Switch on type",
|
|
368
|
+
"documentation": { "value": "A type switch compares types instead of values.\n\n```go\nswitch v := i.(type) {\ncase int:\n fmt.Println(\"int:\", v)\ncase string:\n fmt.Println(\"string:\", v)\ndefault:\n fmt.Printf(\"other: %T\\n\", v)\n}\n```" },
|
|
369
|
+
"insertText": "switch ${1:v} := ${2:i}.(type) {\ncase ${3:int}:\n\t${4}\ncase ${5:string}:\n\t${6}\ndefault:\n\t${0}\n}",
|
|
370
|
+
"insertTextRules": 4,
|
|
371
|
+
"sortText": "00_typeswitch"
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
"label": "for range",
|
|
375
|
+
"kind": 14,
|
|
376
|
+
"detail": "For-range loop",
|
|
377
|
+
"documentation": { "value": "Iterate over a slice, map, string, channel, or integer (Go 1.22+).\n\n```go\nfor i, v := range slice { }\nfor k, v := range myMap { }\nfor i := range 10 { } // Go 1.22+\n```" },
|
|
378
|
+
"insertText": "for ${1:i}, ${2:v} := range ${3:collection} {\n\t${0}\n}",
|
|
379
|
+
"insertTextRules": 4,
|
|
380
|
+
"sortText": "00_forrange"
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
"label": "for range int",
|
|
384
|
+
"kind": 14,
|
|
385
|
+
"detail": "For-range over integer (Go 1.22+)",
|
|
386
|
+
"documentation": { "value": "Iterate from 0 to n-1 using range over an integer (Go 1.22+).\n\n```go\nfor i := range 10 {\n fmt.Println(i) // 0..9\n}\n```" },
|
|
387
|
+
"insertText": "for ${1:i} := range ${2:n} {\n\t${0}\n}",
|
|
388
|
+
"insertTextRules": 4,
|
|
389
|
+
"sortText": "00_forrangeint"
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
"label": "for range func",
|
|
393
|
+
"kind": 14,
|
|
394
|
+
"detail": "Range over function iterator (Go 1.22+)",
|
|
395
|
+
"documentation": { "value": "Range over a function that yields values via a callback (Go 1.22+).\n\n```go\nfor v := range myIterator {\n fmt.Println(v)\n}\n\n// Iterator signature:\n// func(yield func(V) bool)\n```" },
|
|
396
|
+
"insertText": "for ${1:v} := range ${2:iterFunc} {\n\t${0}\n}",
|
|
397
|
+
"insertTextRules": 4,
|
|
398
|
+
"sortText": "00_forrangefunc"
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
"label": "if err != nil",
|
|
402
|
+
"kind": 14,
|
|
403
|
+
"detail": "Error check pattern",
|
|
404
|
+
"documentation": { "value": "Idiomatic Go error handling.\n\n```go\nif err != nil {\n return fmt.Errorf(\"failed: %w\", err)\n}\n```" },
|
|
405
|
+
"insertText": "if err != nil {\n\treturn ${1:err}\n}",
|
|
406
|
+
"insertTextRules": 4,
|
|
407
|
+
"sortText": "00_iferr"
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
"label": "struct",
|
|
411
|
+
"kind": 21,
|
|
412
|
+
"detail": "Struct type declaration",
|
|
413
|
+
"documentation": { "value": "Define a new struct type.\n\n```go\ntype MyStruct struct {\n Field1 string\n Field2 int\n}\n```" },
|
|
414
|
+
"insertText": "type ${1:Name} struct {\n\t${2:Field} ${3:Type}\n\t${0}\n}",
|
|
415
|
+
"insertTextRules": 4,
|
|
416
|
+
"sortText": "00_struct"
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
"label": "interface",
|
|
420
|
+
"kind": 7,
|
|
421
|
+
"detail": "Interface type declaration",
|
|
422
|
+
"documentation": { "value": "Define a new interface type.\n\n```go\ntype MyInterface interface {\n Method(param Type) ReturnType\n}\n```" },
|
|
423
|
+
"insertText": "type ${1:Name} interface {\n\t${2:Method}(${3:params}) ${4:ReturnType}\n\t${0}\n}",
|
|
424
|
+
"insertTextRules": 4,
|
|
425
|
+
"sortText": "00_interface"
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
"label": "defer",
|
|
429
|
+
"kind": 14,
|
|
430
|
+
"detail": "Defer a function call",
|
|
431
|
+
"documentation": { "value": "Defers execution of a function until the surrounding function returns. Deferred calls are executed in LIFO order.\n\n```go\nf, _ := os.Open(\"file.txt\")\ndefer f.Close()\n```" },
|
|
432
|
+
"insertText": "defer ${1:func()}",
|
|
433
|
+
"insertTextRules": 4,
|
|
434
|
+
"sortText": "00_defer"
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
"label": "map literal",
|
|
438
|
+
"kind": 14,
|
|
439
|
+
"detail": "Map literal expression",
|
|
440
|
+
"documentation": { "value": "Create a map with initial values.\n\n```go\nm := map[string]int{\n \"one\": 1,\n \"two\": 2,\n \"three\": 3,\n}\n```" },
|
|
441
|
+
"insertText": "map[${1:string}]${2:int}{\n\t${3:key}: ${4:value},\n\t${0}\n}",
|
|
442
|
+
"insertTextRules": 4,
|
|
443
|
+
"sortText": "00_mapliteral"
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
"label": "slice literal",
|
|
447
|
+
"kind": 14,
|
|
448
|
+
"detail": "Slice literal expression",
|
|
449
|
+
"documentation": { "value": "Create a slice with initial values.\n\n```go\ns := []int{1, 2, 3, 4, 5}\nnames := []string{\"Alice\", \"Bob\"}\n```" },
|
|
450
|
+
"insertText": "[]${1:int}{${2:values}}",
|
|
451
|
+
"insertTextRules": 4,
|
|
452
|
+
"sortText": "00_sliceliteral"
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
"label": "init function",
|
|
456
|
+
"kind": 1,
|
|
457
|
+
"detail": "Package init function",
|
|
458
|
+
"documentation": { "value": "Package initialization function. Each file can have multiple `init` functions. They run before `main()`.\n\n```go\nfunc init() {\n // package-level initialization\n}\n```" },
|
|
459
|
+
"insertText": "func init() {\n\t${0}\n}",
|
|
460
|
+
"insertTextRules": 4,
|
|
461
|
+
"sortText": "00_init"
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
"label": "main function",
|
|
465
|
+
"kind": 1,
|
|
466
|
+
"detail": "Program entry point",
|
|
467
|
+
"documentation": { "value": "The entry point for an executable Go program.\n\n```go\nfunc main() {\n fmt.Println(\"Hello, world!\")\n}\n```" },
|
|
468
|
+
"insertText": "func main() {\n\t${0}\n}",
|
|
469
|
+
"insertTextRules": 4,
|
|
470
|
+
"sortText": "00_main"
|
|
471
|
+
},
|
|
472
|
+
{
|
|
473
|
+
"label": "test function",
|
|
474
|
+
"kind": 1,
|
|
475
|
+
"detail": "Test function",
|
|
476
|
+
"documentation": { "value": "A test function for `go test`. Must start with `Test` and accept `*testing.T`.\n\n```go\nfunc TestSomething(t *testing.T) {\n got := Add(1, 2)\n if got != 3 {\n t.Errorf(\"Add(1,2) = %d, want 3\", got)\n }\n}\n```" },
|
|
477
|
+
"insertText": "func Test${1:Name}(t *testing.T) {\n\t${0}\n}",
|
|
478
|
+
"insertTextRules": 4,
|
|
479
|
+
"sortText": "00_test"
|
|
480
|
+
},
|
|
481
|
+
{
|
|
482
|
+
"label": "benchmark function",
|
|
483
|
+
"kind": 1,
|
|
484
|
+
"detail": "Benchmark function",
|
|
485
|
+
"documentation": { "value": "A benchmark function for `go test -bench`. Must start with `Benchmark` and accept `*testing.B`.\n\n```go\nfunc BenchmarkSomething(b *testing.B) {\n for i := 0; i < b.N; i++ {\n // code to benchmark\n }\n}\n```" },
|
|
486
|
+
"insertText": "func Benchmark${1:Name}(b *testing.B) {\n\tfor i := 0; i < b.N; i++ {\n\t\t${0}\n\t}\n}",
|
|
487
|
+
"insertTextRules": 4,
|
|
488
|
+
"sortText": "00_benchmark"
|
|
489
|
+
},
|
|
490
|
+
{
|
|
491
|
+
"label": "table-driven test",
|
|
492
|
+
"kind": 14,
|
|
493
|
+
"detail": "Table-driven test pattern",
|
|
494
|
+
"documentation": { "value": "Idiomatic Go table-driven test pattern.\n\n```go\ntests := []struct{\n name string\n input int\n want int\n}{\n {\"case1\", 1, 2},\n}\nfor _, tt := range tests {\n t.Run(tt.name, func(t *testing.T) {\n // ...\n })\n}\n```" },
|
|
495
|
+
"insertText": "tests := []struct {\n\tname string\n\t${1:input} ${2:Type}\n\twant ${3:Type}\n}{\n\t{\"${4:case}\", ${5:input}, ${6:want}},\n}\nfor _, tt := range tests {\n\tt.Run(tt.name, func(t *testing.T) {\n\t\t${0}\n\t})\n}",
|
|
496
|
+
"insertTextRules": 4,
|
|
497
|
+
"sortText": "00_tabletest"
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
"label": "strings.Contains",
|
|
501
|
+
"kind": 1,
|
|
502
|
+
"detail": "Check if string contains substring",
|
|
503
|
+
"documentation": { "value": "Reports whether `substr` is within `s`.\n\n```go\nstrings.Contains(\"seafood\", \"foo\") // true\nstrings.Contains(\"hello\", \"xyz\") // false\n```" },
|
|
504
|
+
"insertText": "strings.Contains(${1:s}, ${2:substr})",
|
|
505
|
+
"insertTextRules": 4,
|
|
506
|
+
"sortText": "01_strings_contains"
|
|
507
|
+
},
|
|
508
|
+
{
|
|
509
|
+
"label": "strings.HasPrefix",
|
|
510
|
+
"kind": 1,
|
|
511
|
+
"detail": "Check if string starts with prefix",
|
|
512
|
+
"documentation": { "value": "Reports whether the string `s` begins with `prefix`.\n\n```go\nstrings.HasPrefix(\"/api/users\", \"/api\") // true\n```" },
|
|
513
|
+
"insertText": "strings.HasPrefix(${1:s}, ${2:prefix})",
|
|
514
|
+
"insertTextRules": 4,
|
|
515
|
+
"sortText": "01_strings_hasprefix"
|
|
516
|
+
},
|
|
517
|
+
{
|
|
518
|
+
"label": "strings.Split",
|
|
519
|
+
"kind": 1,
|
|
520
|
+
"detail": "Split string by separator",
|
|
521
|
+
"documentation": { "value": "Slices `s` into all substrings separated by `sep`.\n\n```go\nparts := strings.Split(\"a,b,c\", \",\") // [\"a\" \"b\" \"c\"]\nlines := strings.Split(text, \"\\n\")\n```" },
|
|
522
|
+
"insertText": "strings.Split(${1:s}, ${2:sep})",
|
|
523
|
+
"insertTextRules": 4,
|
|
524
|
+
"sortText": "01_strings_split"
|
|
525
|
+
},
|
|
526
|
+
{
|
|
527
|
+
"label": "strings.Join",
|
|
528
|
+
"kind": 1,
|
|
529
|
+
"detail": "Join string slice with separator",
|
|
530
|
+
"documentation": { "value": "Concatenates the elements of a string slice with a separator.\n\n```go\nresult := strings.Join([]string{\"a\", \"b\", \"c\"}, \", \") // \"a, b, c\"\n```" },
|
|
531
|
+
"insertText": "strings.Join(${1:elems}, ${2:sep})",
|
|
532
|
+
"insertTextRules": 4,
|
|
533
|
+
"sortText": "01_strings_join"
|
|
534
|
+
},
|
|
535
|
+
{
|
|
536
|
+
"label": "strings.TrimSpace",
|
|
537
|
+
"kind": 1,
|
|
538
|
+
"detail": "Trim leading and trailing whitespace",
|
|
539
|
+
"documentation": { "value": "Returns a string with all leading and trailing whitespace removed.\n\n```go\ns := strings.TrimSpace(\" hello \") // \"hello\"\n```" },
|
|
540
|
+
"insertText": "strings.TrimSpace(${1:s})",
|
|
541
|
+
"insertTextRules": 4,
|
|
542
|
+
"sortText": "01_strings_trimspace"
|
|
543
|
+
},
|
|
544
|
+
{
|
|
545
|
+
"label": "strings.Replace",
|
|
546
|
+
"kind": 1,
|
|
547
|
+
"detail": "Replace occurrences in string",
|
|
548
|
+
"documentation": { "value": "Returns a copy of `s` with the first `n` non-overlapping instances of `old` replaced by `new`. If `n < 0`, replace all.\n\n```go\ns := strings.Replace(\"oink oink\", \"oink\", \"moo\", -1) // \"moo moo\"\n```" },
|
|
549
|
+
"insertText": "strings.Replace(${1:s}, ${2:old}, ${3:new}, ${4:-1})",
|
|
550
|
+
"insertTextRules": 4,
|
|
551
|
+
"sortText": "01_strings_replace"
|
|
552
|
+
},
|
|
553
|
+
{
|
|
554
|
+
"label": "strings.Builder",
|
|
555
|
+
"kind": 21,
|
|
556
|
+
"detail": "Efficient string builder",
|
|
557
|
+
"documentation": { "value": "A `Builder` is used to efficiently build a string using `Write` methods. Minimizes memory copying.\n\n```go\nvar b strings.Builder\nb.WriteString(\"Hello\")\nb.WriteString(\", \")\nb.WriteString(\"world!\")\nresult := b.String()\n```" },
|
|
558
|
+
"insertText": "var ${1:b} strings.Builder\n${1:b}.WriteString(${2:s})\n${0}",
|
|
559
|
+
"insertTextRules": 4,
|
|
560
|
+
"sortText": "01_strings_builder"
|
|
561
|
+
},
|
|
562
|
+
{
|
|
563
|
+
"label": "strconv.Atoi",
|
|
564
|
+
"kind": 1,
|
|
565
|
+
"detail": "Convert string to int",
|
|
566
|
+
"documentation": { "value": "Parses a string as a decimal integer.\n\n```go\nn, err := strconv.Atoi(\"42\")\nif err != nil { log.Fatal(err) }\n```" },
|
|
567
|
+
"insertText": "strconv.Atoi(${1:s})",
|
|
568
|
+
"insertTextRules": 4,
|
|
569
|
+
"sortText": "01_strconv_atoi"
|
|
570
|
+
},
|
|
571
|
+
{
|
|
572
|
+
"label": "strconv.Itoa",
|
|
573
|
+
"kind": 1,
|
|
574
|
+
"detail": "Convert int to string",
|
|
575
|
+
"documentation": { "value": "Returns the string representation of an integer.\n\n```go\ns := strconv.Itoa(42) // \"42\"\n```" },
|
|
576
|
+
"insertText": "strconv.Itoa(${1:n})",
|
|
577
|
+
"insertTextRules": 4,
|
|
578
|
+
"sortText": "01_strconv_itoa"
|
|
579
|
+
},
|
|
580
|
+
{
|
|
581
|
+
"label": "strconv.FormatFloat",
|
|
582
|
+
"kind": 1,
|
|
583
|
+
"detail": "Convert float to string",
|
|
584
|
+
"documentation": { "value": "Converts a float64 to a string with the given format and precision.\n\n```go\ns := strconv.FormatFloat(3.14, 'f', 2, 64) // \"3.14\"\n```" },
|
|
585
|
+
"insertText": "strconv.FormatFloat(${1:f}, '${2:f}', ${3:2}, ${4:64})",
|
|
586
|
+
"insertTextRules": 4,
|
|
587
|
+
"sortText": "01_strconv_formatfloat"
|
|
588
|
+
},
|
|
589
|
+
{
|
|
590
|
+
"label": "strconv.ParseInt",
|
|
591
|
+
"kind": 1,
|
|
592
|
+
"detail": "Parse string as integer with base",
|
|
593
|
+
"documentation": { "value": "Interprets a string in the given base and bit size.\n\n```go\nn, err := strconv.ParseInt(\"FF\", 16, 64) // 255\n```" },
|
|
594
|
+
"insertText": "strconv.ParseInt(${1:s}, ${2:10}, ${3:64})",
|
|
595
|
+
"insertTextRules": 4,
|
|
596
|
+
"sortText": "01_strconv_parseint"
|
|
597
|
+
},
|
|
598
|
+
{
|
|
599
|
+
"label": "os.Open",
|
|
600
|
+
"kind": 1,
|
|
601
|
+
"detail": "Open a file for reading",
|
|
602
|
+
"documentation": { "value": "Opens the named file for reading.\n\n```go\nf, err := os.Open(\"file.txt\")\nif err != nil { log.Fatal(err) }\ndefer f.Close()\n```" },
|
|
603
|
+
"insertText": "${1:f}, ${2:err} := os.Open(${3:name})",
|
|
604
|
+
"insertTextRules": 4,
|
|
605
|
+
"sortText": "01_os_open"
|
|
606
|
+
},
|
|
607
|
+
{
|
|
608
|
+
"label": "os.Create",
|
|
609
|
+
"kind": 1,
|
|
610
|
+
"detail": "Create or truncate a file",
|
|
611
|
+
"documentation": { "value": "Creates or truncates the named file for writing.\n\n```go\nf, err := os.Create(\"output.txt\")\nif err != nil { log.Fatal(err) }\ndefer f.Close()\n```" },
|
|
612
|
+
"insertText": "${1:f}, ${2:err} := os.Create(${3:name})",
|
|
613
|
+
"insertTextRules": 4,
|
|
614
|
+
"sortText": "01_os_create"
|
|
615
|
+
},
|
|
616
|
+
{
|
|
617
|
+
"label": "os.ReadFile",
|
|
618
|
+
"kind": 1,
|
|
619
|
+
"detail": "Read entire file into []byte",
|
|
620
|
+
"documentation": { "value": "Reads the named file and returns the contents.\n\n```go\ndata, err := os.ReadFile(\"config.json\")\nif err != nil { log.Fatal(err) }\n```" },
|
|
621
|
+
"insertText": "${1:data}, ${2:err} := os.ReadFile(${3:name})",
|
|
622
|
+
"insertTextRules": 4,
|
|
623
|
+
"sortText": "01_os_readfile"
|
|
624
|
+
},
|
|
625
|
+
{
|
|
626
|
+
"label": "os.WriteFile",
|
|
627
|
+
"kind": 1,
|
|
628
|
+
"detail": "Write data to a file",
|
|
629
|
+
"documentation": { "value": "Writes data to the named file, creating it if necessary.\n\n```go\nerr := os.WriteFile(\"data.txt\", []byte(\"hello\"), 0644)\n```" },
|
|
630
|
+
"insertText": "os.WriteFile(${1:name}, ${2:data}, ${3:0644})",
|
|
631
|
+
"insertTextRules": 4,
|
|
632
|
+
"sortText": "01_os_writefile"
|
|
633
|
+
},
|
|
634
|
+
{
|
|
635
|
+
"label": "os.Args",
|
|
636
|
+
"kind": 9,
|
|
637
|
+
"detail": "Command-line arguments",
|
|
638
|
+
"documentation": { "value": "A slice of strings holding the command-line arguments, starting with the program name.\n\n```go\nif len(os.Args) < 2 {\n fmt.Println(\"Usage: cmd <arg>\")\n os.Exit(1)\n}\narg := os.Args[1]\n```" },
|
|
639
|
+
"insertText": "os.Args",
|
|
640
|
+
"insertTextRules": 0,
|
|
641
|
+
"sortText": "01_os_args"
|
|
642
|
+
},
|
|
643
|
+
{
|
|
644
|
+
"label": "os.Exit",
|
|
645
|
+
"kind": 1,
|
|
646
|
+
"detail": "Exit the program with status code",
|
|
647
|
+
"documentation": { "value": "Causes the current program to exit with the given status code. Deferred functions are not run.\n\n```go\nos.Exit(0) // success\nos.Exit(1) // failure\n```" },
|
|
648
|
+
"insertText": "os.Exit(${1:0})",
|
|
649
|
+
"insertTextRules": 4,
|
|
650
|
+
"sortText": "01_os_exit"
|
|
651
|
+
},
|
|
652
|
+
{
|
|
653
|
+
"label": "os.Getenv",
|
|
654
|
+
"kind": 1,
|
|
655
|
+
"detail": "Get environment variable",
|
|
656
|
+
"documentation": { "value": "Retrieves the value of the environment variable named by the key.\n\n```go\nport := os.Getenv(\"PORT\")\nhome := os.Getenv(\"HOME\")\n```" },
|
|
657
|
+
"insertText": "os.Getenv(${1:key})",
|
|
658
|
+
"insertTextRules": 4,
|
|
659
|
+
"sortText": "01_os_getenv"
|
|
660
|
+
},
|
|
661
|
+
{
|
|
662
|
+
"label": "os.Setenv",
|
|
663
|
+
"kind": 1,
|
|
664
|
+
"detail": "Set environment variable",
|
|
665
|
+
"documentation": { "value": "Sets the value of the environment variable named by the key.\n\n```go\nos.Setenv(\"PORT\", \"8080\")\n```" },
|
|
666
|
+
"insertText": "os.Setenv(${1:key}, ${2:value})",
|
|
667
|
+
"insertTextRules": 4,
|
|
668
|
+
"sortText": "01_os_setenv"
|
|
669
|
+
},
|
|
670
|
+
{
|
|
671
|
+
"label": "os.MkdirAll",
|
|
672
|
+
"kind": 1,
|
|
673
|
+
"detail": "Create directory tree",
|
|
674
|
+
"documentation": { "value": "Creates a directory named path, along with any necessary parents.\n\n```go\nerr := os.MkdirAll(\"path/to/dir\", 0755)\n```" },
|
|
675
|
+
"insertText": "os.MkdirAll(${1:path}, ${2:0755})",
|
|
676
|
+
"insertTextRules": 4,
|
|
677
|
+
"sortText": "01_os_mkdirall"
|
|
678
|
+
},
|
|
679
|
+
{
|
|
680
|
+
"label": "os.Remove",
|
|
681
|
+
"kind": 1,
|
|
682
|
+
"detail": "Remove a file or empty directory",
|
|
683
|
+
"documentation": { "value": "Removes the named file or empty directory.\n\n```go\nerr := os.Remove(\"temp.txt\")\n```" },
|
|
684
|
+
"insertText": "os.Remove(${1:name})",
|
|
685
|
+
"insertTextRules": 4,
|
|
686
|
+
"sortText": "01_os_remove"
|
|
687
|
+
},
|
|
688
|
+
{
|
|
689
|
+
"label": "io.ReadAll",
|
|
690
|
+
"kind": 1,
|
|
691
|
+
"detail": "Read all bytes from reader",
|
|
692
|
+
"documentation": { "value": "Reads from r until an error or EOF and returns the data.\n\n```go\ndata, err := io.ReadAll(resp.Body)\n```" },
|
|
693
|
+
"insertText": "${1:data}, ${2:err} := io.ReadAll(${3:r})",
|
|
694
|
+
"insertTextRules": 4,
|
|
695
|
+
"sortText": "01_io_readall"
|
|
696
|
+
},
|
|
697
|
+
{
|
|
698
|
+
"label": "io.Copy",
|
|
699
|
+
"kind": 1,
|
|
700
|
+
"detail": "Copy from reader to writer",
|
|
701
|
+
"documentation": { "value": "Copies from `src` to `dst` until either EOF is reached on `src` or an error occurs.\n\n```go\nn, err := io.Copy(dst, src)\nio.Copy(os.Stdout, resp.Body)\n```" },
|
|
702
|
+
"insertText": "io.Copy(${1:dst}, ${2:src})",
|
|
703
|
+
"insertTextRules": 4,
|
|
704
|
+
"sortText": "01_io_copy"
|
|
705
|
+
},
|
|
706
|
+
{
|
|
707
|
+
"label": "io.NopCloser",
|
|
708
|
+
"kind": 1,
|
|
709
|
+
"detail": "Wrap reader with no-op Close",
|
|
710
|
+
"documentation": { "value": "Returns a ReadCloser with a no-op Close method wrapping the provided Reader.\n\n```go\nrc := io.NopCloser(strings.NewReader(\"hello\"))\n```" },
|
|
711
|
+
"insertText": "io.NopCloser(${1:r})",
|
|
712
|
+
"insertTextRules": 4,
|
|
713
|
+
"sortText": "01_io_nopcloser"
|
|
714
|
+
},
|
|
715
|
+
{
|
|
716
|
+
"label": "http.ListenAndServe",
|
|
717
|
+
"kind": 1,
|
|
718
|
+
"detail": "Start HTTP server",
|
|
719
|
+
"documentation": { "value": "Listens on the TCP network address and serves requests using the handler.\n\n```go\nlog.Fatal(http.ListenAndServe(\":8080\", nil))\nlog.Fatal(http.ListenAndServe(\":8080\", mux))\n```" },
|
|
720
|
+
"insertText": "http.ListenAndServe(${1:\":8080\"}, ${2:nil})",
|
|
721
|
+
"insertTextRules": 4,
|
|
722
|
+
"sortText": "01_http_listenandserve"
|
|
723
|
+
},
|
|
724
|
+
{
|
|
725
|
+
"label": "http.HandleFunc",
|
|
726
|
+
"kind": 1,
|
|
727
|
+
"detail": "Register HTTP handler function",
|
|
728
|
+
"documentation": { "value": "Registers the handler function for the given pattern.\n\n```go\nhttp.HandleFunc(\"/hello\", func(w http.ResponseWriter, r *http.Request) {\n fmt.Fprintf(w, \"Hello, World!\")\n})\n```" },
|
|
729
|
+
"insertText": "http.HandleFunc(\"${1:/path}\", func(w http.ResponseWriter, r *http.Request) {\n\t${0}\n})",
|
|
730
|
+
"insertTextRules": 4,
|
|
731
|
+
"sortText": "01_http_handlefunc"
|
|
732
|
+
},
|
|
733
|
+
{
|
|
734
|
+
"label": "http.Get",
|
|
735
|
+
"kind": 1,
|
|
736
|
+
"detail": "HTTP GET request",
|
|
737
|
+
"documentation": { "value": "Issues an HTTP GET to the specified URL.\n\n```go\nresp, err := http.Get(\"https://example.com\")\nif err != nil { log.Fatal(err) }\ndefer resp.Body.Close()\n```" },
|
|
738
|
+
"insertText": "${1:resp}, ${2:err} := http.Get(${3:url})",
|
|
739
|
+
"insertTextRules": 4,
|
|
740
|
+
"sortText": "01_http_get"
|
|
741
|
+
},
|
|
742
|
+
{
|
|
743
|
+
"label": "http.Post",
|
|
744
|
+
"kind": 1,
|
|
745
|
+
"detail": "HTTP POST request",
|
|
746
|
+
"documentation": { "value": "Issues a POST to the specified URL.\n\n```go\nresp, err := http.Post(url, \"application/json\", bytes.NewBuffer(jsonData))\nif err != nil { log.Fatal(err) }\ndefer resp.Body.Close()\n```" },
|
|
747
|
+
"insertText": "${1:resp}, ${2:err} := http.Post(${3:url}, ${4:\"application/json\"}, ${5:body})",
|
|
748
|
+
"insertTextRules": 4,
|
|
749
|
+
"sortText": "01_http_post"
|
|
750
|
+
},
|
|
751
|
+
{
|
|
752
|
+
"label": "http.NewRequest",
|
|
753
|
+
"kind": 1,
|
|
754
|
+
"detail": "Create a new HTTP request",
|
|
755
|
+
"documentation": { "value": "Creates a new HTTP request with the given method, URL, and optional body.\n\n```go\nreq, err := http.NewRequest(\"GET\", url, nil)\nreq.Header.Set(\"Authorization\", \"Bearer \"+token)\n```" },
|
|
756
|
+
"insertText": "${1:req}, ${2:err} := http.NewRequest(${3:\"GET\"}, ${4:url}, ${5:nil})",
|
|
757
|
+
"insertTextRules": 4,
|
|
758
|
+
"sortText": "01_http_newrequest"
|
|
759
|
+
},
|
|
760
|
+
{
|
|
761
|
+
"label": "http.NewServeMux",
|
|
762
|
+
"kind": 1,
|
|
763
|
+
"detail": "Create a new HTTP request multiplexer",
|
|
764
|
+
"documentation": { "value": "Allocates and returns a new ServeMux.\n\n```go\nmux := http.NewServeMux()\nmux.HandleFunc(\"/api/\", apiHandler)\nhttp.ListenAndServe(\":8080\", mux)\n```" },
|
|
765
|
+
"insertText": "${1:mux} := http.NewServeMux()\n${1:mux}.HandleFunc(\"${2:/path}\", ${3:handler})",
|
|
766
|
+
"insertTextRules": 4,
|
|
767
|
+
"sortText": "01_http_newservemux"
|
|
768
|
+
},
|
|
769
|
+
{
|
|
770
|
+
"label": "json.Marshal",
|
|
771
|
+
"kind": 1,
|
|
772
|
+
"detail": "Encode value to JSON",
|
|
773
|
+
"documentation": { "value": "Returns the JSON encoding of v.\n\n```go\ndata, err := json.Marshal(myStruct)\nif err != nil { log.Fatal(err) }\nfmt.Println(string(data))\n```" },
|
|
774
|
+
"insertText": "${1:data}, ${2:err} := json.Marshal(${3:v})",
|
|
775
|
+
"insertTextRules": 4,
|
|
776
|
+
"sortText": "01_json_marshal"
|
|
777
|
+
},
|
|
778
|
+
{
|
|
779
|
+
"label": "json.Unmarshal",
|
|
780
|
+
"kind": 1,
|
|
781
|
+
"detail": "Decode JSON to value",
|
|
782
|
+
"documentation": { "value": "Parses the JSON-encoded data and stores the result in the value pointed to by v.\n\n```go\nvar result MyStruct\nerr := json.Unmarshal(data, &result)\nif err != nil { log.Fatal(err) }\n```" },
|
|
783
|
+
"insertText": "json.Unmarshal(${1:data}, &${2:v})",
|
|
784
|
+
"insertTextRules": 4,
|
|
785
|
+
"sortText": "01_json_unmarshal"
|
|
786
|
+
},
|
|
787
|
+
{
|
|
788
|
+
"label": "json.NewEncoder",
|
|
789
|
+
"kind": 1,
|
|
790
|
+
"detail": "Create JSON encoder for writer",
|
|
791
|
+
"documentation": { "value": "Creates a new encoder that writes to w.\n\n```go\njson.NewEncoder(w).Encode(myStruct)\n```" },
|
|
792
|
+
"insertText": "json.NewEncoder(${1:w}).Encode(${2:v})",
|
|
793
|
+
"insertTextRules": 4,
|
|
794
|
+
"sortText": "01_json_newencoder"
|
|
795
|
+
},
|
|
796
|
+
{
|
|
797
|
+
"label": "json.NewDecoder",
|
|
798
|
+
"kind": 1,
|
|
799
|
+
"detail": "Create JSON decoder for reader",
|
|
800
|
+
"documentation": { "value": "Creates a new decoder that reads from r.\n\n```go\nvar result MyStruct\njson.NewDecoder(r).Decode(&result)\n```" },
|
|
801
|
+
"insertText": "json.NewDecoder(${1:r}).Decode(&${2:v})",
|
|
802
|
+
"insertTextRules": 4,
|
|
803
|
+
"sortText": "01_json_newdecoder"
|
|
804
|
+
},
|
|
805
|
+
{
|
|
806
|
+
"label": "json.RawMessage",
|
|
807
|
+
"kind": 14,
|
|
808
|
+
"detail": "Raw encoded JSON value",
|
|
809
|
+
"documentation": { "value": "A raw encoded JSON value. It can be used to delay JSON decoding or precompute a JSON encoding.\n\n```go\ntype Response struct {\n Data json.RawMessage `json:\"data\"`\n}\n```" },
|
|
810
|
+
"insertText": "json.RawMessage",
|
|
811
|
+
"insertTextRules": 0,
|
|
812
|
+
"sortText": "01_json_rawmessage"
|
|
813
|
+
},
|
|
814
|
+
{
|
|
815
|
+
"label": "errors.New",
|
|
816
|
+
"kind": 1,
|
|
817
|
+
"detail": "Create a new error",
|
|
818
|
+
"documentation": { "value": "Returns an error that formats as the given text.\n\n```go\nvar ErrNotFound = errors.New(\"not found\")\nreturn errors.New(\"something went wrong\")\n```" },
|
|
819
|
+
"insertText": "errors.New(${1:\"error message\"})",
|
|
820
|
+
"insertTextRules": 4,
|
|
821
|
+
"sortText": "01_errors_new"
|
|
822
|
+
},
|
|
823
|
+
{
|
|
824
|
+
"label": "errors.Is",
|
|
825
|
+
"kind": 1,
|
|
826
|
+
"detail": "Check if error matches target",
|
|
827
|
+
"documentation": { "value": "Reports whether any error in err's chain matches target.\n\n```go\nif errors.Is(err, os.ErrNotExist) {\n // file does not exist\n}\n```" },
|
|
828
|
+
"insertText": "errors.Is(${1:err}, ${2:target})",
|
|
829
|
+
"insertTextRules": 4,
|
|
830
|
+
"sortText": "01_errors_is"
|
|
831
|
+
},
|
|
832
|
+
{
|
|
833
|
+
"label": "errors.As",
|
|
834
|
+
"kind": 1,
|
|
835
|
+
"detail": "Extract error of specific type",
|
|
836
|
+
"documentation": { "value": "Finds the first error in err's chain that matches target and sets target to that error value.\n\n```go\nvar pathErr *os.PathError\nif errors.As(err, &pathErr) {\n fmt.Println(pathErr.Path)\n}\n```" },
|
|
837
|
+
"insertText": "errors.As(${1:err}, &${2:target})",
|
|
838
|
+
"insertTextRules": 4,
|
|
839
|
+
"sortText": "01_errors_as"
|
|
840
|
+
},
|
|
841
|
+
{
|
|
842
|
+
"label": "errors.Join",
|
|
843
|
+
"kind": 1,
|
|
844
|
+
"detail": "Join multiple errors (Go 1.20+)",
|
|
845
|
+
"documentation": { "value": "Returns an error that wraps the given errors. Any nil error values are discarded.\n\n```go\nerr := errors.Join(err1, err2, err3)\n```" },
|
|
846
|
+
"insertText": "errors.Join(${1:errs})",
|
|
847
|
+
"insertTextRules": 4,
|
|
848
|
+
"sortText": "01_errors_join"
|
|
849
|
+
},
|
|
850
|
+
{
|
|
851
|
+
"label": "errors.Unwrap",
|
|
852
|
+
"kind": 1,
|
|
853
|
+
"detail": "Unwrap an error",
|
|
854
|
+
"documentation": { "value": "Returns the result of calling the Unwrap method on err, if it implements `Unwrap() error`.\n\n```go\ninner := errors.Unwrap(err)\n```" },
|
|
855
|
+
"insertText": "errors.Unwrap(${1:err})",
|
|
856
|
+
"insertTextRules": 4,
|
|
857
|
+
"sortText": "01_errors_unwrap"
|
|
858
|
+
},
|
|
859
|
+
{
|
|
860
|
+
"label": "context.Background",
|
|
861
|
+
"kind": 1,
|
|
862
|
+
"detail": "Return a non-nil empty context",
|
|
863
|
+
"documentation": { "value": "Returns a non-nil, empty Context. It is never canceled, has no values, and has no deadline. Typically used in main, init, and tests.\n\n```go\nctx := context.Background()\n```" },
|
|
864
|
+
"insertText": "context.Background()",
|
|
865
|
+
"insertTextRules": 4,
|
|
866
|
+
"sortText": "01_context_background"
|
|
867
|
+
},
|
|
868
|
+
{
|
|
869
|
+
"label": "context.TODO",
|
|
870
|
+
"kind": 1,
|
|
871
|
+
"detail": "Return a placeholder context",
|
|
872
|
+
"documentation": { "value": "Returns a non-nil, empty Context. Use when it's unclear which Context to use or when the surrounding function has not yet been extended to accept a Context parameter.\n\n```go\nctx := context.TODO()\n```" },
|
|
873
|
+
"insertText": "context.TODO()",
|
|
874
|
+
"insertTextRules": 4,
|
|
875
|
+
"sortText": "01_context_todo"
|
|
876
|
+
},
|
|
877
|
+
{
|
|
878
|
+
"label": "context.WithCancel",
|
|
879
|
+
"kind": 1,
|
|
880
|
+
"detail": "Create cancellable context",
|
|
881
|
+
"documentation": { "value": "Returns a copy of parent with a new Done channel. Call cancel to release resources.\n\n```go\nctx, cancel := context.WithCancel(context.Background())\ndefer cancel()\n```" },
|
|
882
|
+
"insertText": "${1:ctx}, ${2:cancel} := context.WithCancel(${3:ctx})\ndefer ${2:cancel}()",
|
|
883
|
+
"insertTextRules": 4,
|
|
884
|
+
"sortText": "01_context_withcancel"
|
|
885
|
+
},
|
|
886
|
+
{
|
|
887
|
+
"label": "context.WithTimeout",
|
|
888
|
+
"kind": 1,
|
|
889
|
+
"detail": "Create context with timeout",
|
|
890
|
+
"documentation": { "value": "Returns a copy of parent whose Done channel is closed after the timeout elapses.\n\n```go\nctx, cancel := context.WithTimeout(ctx, 5*time.Second)\ndefer cancel()\n```" },
|
|
891
|
+
"insertText": "${1:ctx}, ${2:cancel} := context.WithTimeout(${3:ctx}, ${4:5*time.Second})\ndefer ${2:cancel}()",
|
|
892
|
+
"insertTextRules": 4,
|
|
893
|
+
"sortText": "01_context_withtimeout"
|
|
894
|
+
},
|
|
895
|
+
{
|
|
896
|
+
"label": "context.WithValue",
|
|
897
|
+
"kind": 1,
|
|
898
|
+
"detail": "Create context with value",
|
|
899
|
+
"documentation": { "value": "Returns a copy of parent in which the value associated with key is val.\n\n```go\nctx := context.WithValue(ctx, myKey, myValue)\n```" },
|
|
900
|
+
"insertText": "context.WithValue(${1:ctx}, ${2:key}, ${3:val})",
|
|
901
|
+
"insertTextRules": 4,
|
|
902
|
+
"sortText": "01_context_withvalue"
|
|
903
|
+
},
|
|
904
|
+
{
|
|
905
|
+
"label": "context.WithDeadline",
|
|
906
|
+
"kind": 1,
|
|
907
|
+
"detail": "Create context with deadline",
|
|
908
|
+
"documentation": { "value": "Returns a copy of parent whose Done channel is closed after the deadline expires.\n\n```go\ndeadline := time.Now().Add(30 * time.Second)\nctx, cancel := context.WithDeadline(ctx, deadline)\ndefer cancel()\n```" },
|
|
909
|
+
"insertText": "${1:ctx}, ${2:cancel} := context.WithDeadline(${3:ctx}, ${4:deadline})\ndefer ${2:cancel}()",
|
|
910
|
+
"insertTextRules": 4,
|
|
911
|
+
"sortText": "01_context_withdeadline"
|
|
912
|
+
},
|
|
913
|
+
{
|
|
914
|
+
"label": "sync.Mutex",
|
|
915
|
+
"kind": 21,
|
|
916
|
+
"detail": "Mutual exclusion lock",
|
|
917
|
+
"documentation": { "value": "A `Mutex` is a mutual exclusion lock. Zero value is an unlocked mutex.\n\n```go\nvar mu sync.Mutex\nmu.Lock()\ndefer mu.Unlock()\n// critical section\n```" },
|
|
918
|
+
"insertText": "var ${1:mu} sync.Mutex\n${1:mu}.Lock()\ndefer ${1:mu}.Unlock()\n${0}",
|
|
919
|
+
"insertTextRules": 4,
|
|
920
|
+
"sortText": "01_sync_mutex"
|
|
921
|
+
},
|
|
922
|
+
{
|
|
923
|
+
"label": "sync.WaitGroup",
|
|
924
|
+
"kind": 21,
|
|
925
|
+
"detail": "Wait for goroutines to finish",
|
|
926
|
+
"documentation": { "value": "A `WaitGroup` waits for a collection of goroutines to finish.\n\n```go\nvar wg sync.WaitGroup\nwg.Add(1)\ngo func() {\n defer wg.Done()\n // work\n}()\nwg.Wait()\n```" },
|
|
927
|
+
"insertText": "var ${1:wg} sync.WaitGroup\n${1:wg}.Add(${2:1})\ngo func() {\n\tdefer ${1:wg}.Done()\n\t${0}\n}()\n${1:wg}.Wait()",
|
|
928
|
+
"insertTextRules": 4,
|
|
929
|
+
"sortText": "01_sync_waitgroup"
|
|
930
|
+
},
|
|
931
|
+
{
|
|
932
|
+
"label": "sync.Once",
|
|
933
|
+
"kind": 21,
|
|
934
|
+
"detail": "Execute action exactly once",
|
|
935
|
+
"documentation": { "value": "An object that will perform exactly one action.\n\n```go\nvar once sync.Once\nonce.Do(func() {\n // initialization\n})\n```" },
|
|
936
|
+
"insertText": "var ${1:once} sync.Once\n${1:once}.Do(func() {\n\t${0}\n})",
|
|
937
|
+
"insertTextRules": 4,
|
|
938
|
+
"sortText": "01_sync_once"
|
|
939
|
+
},
|
|
940
|
+
{
|
|
941
|
+
"label": "sync.Map",
|
|
942
|
+
"kind": 21,
|
|
943
|
+
"detail": "Concurrent-safe map",
|
|
944
|
+
"documentation": { "value": "A `Map` is like a Go `map[any]any` but is safe for concurrent use without additional locking.\n\n```go\nvar m sync.Map\nm.Store(\"key\", \"value\")\nv, ok := m.Load(\"key\")\nm.Delete(\"key\")\n```" },
|
|
945
|
+
"insertText": "var ${1:m} sync.Map\n${1:m}.Store(${2:key}, ${3:value})\n${0}",
|
|
946
|
+
"insertTextRules": 4,
|
|
947
|
+
"sortText": "01_sync_map"
|
|
948
|
+
},
|
|
949
|
+
{
|
|
950
|
+
"label": "sync.Pool",
|
|
951
|
+
"kind": 21,
|
|
952
|
+
"detail": "Object pool for reuse",
|
|
953
|
+
"documentation": { "value": "A `Pool` is a set of temporary objects that may be individually saved and retrieved.\n\n```go\nvar pool = sync.Pool{\n New: func() any { return new(bytes.Buffer) },\n}\nbuf := pool.Get().(*bytes.Buffer)\ndefer pool.Put(buf)\n```" },
|
|
954
|
+
"insertText": "var ${1:pool} = sync.Pool{\n\tNew: func() any {\n\t\treturn ${2:new(Type)}\n\t},\n}",
|
|
955
|
+
"insertTextRules": 4,
|
|
956
|
+
"sortText": "01_sync_pool"
|
|
957
|
+
},
|
|
958
|
+
{
|
|
959
|
+
"label": "sync.RWMutex",
|
|
960
|
+
"kind": 21,
|
|
961
|
+
"detail": "Reader/writer mutual exclusion lock",
|
|
962
|
+
"documentation": { "value": "An `RWMutex` allows multiple readers or one writer. Zero value is unlocked.\n\n```go\nvar mu sync.RWMutex\nmu.RLock()\ndefer mu.RUnlock()\n// read-only section\n```" },
|
|
963
|
+
"insertText": "var ${1:mu} sync.RWMutex\n${1:mu}.RLock()\ndefer ${1:mu}.RUnlock()\n${0}",
|
|
964
|
+
"insertTextRules": 4,
|
|
965
|
+
"sortText": "01_sync_rwmutex"
|
|
966
|
+
},
|
|
967
|
+
{
|
|
968
|
+
"label": "time.Now",
|
|
969
|
+
"kind": 1,
|
|
970
|
+
"detail": "Get current time",
|
|
971
|
+
"documentation": { "value": "Returns the current local time.\n\n```go\nnow := time.Now()\nfmt.Println(now.Format(time.RFC3339))\n```" },
|
|
972
|
+
"insertText": "time.Now()",
|
|
973
|
+
"insertTextRules": 4,
|
|
974
|
+
"sortText": "01_time_now"
|
|
975
|
+
},
|
|
976
|
+
{
|
|
977
|
+
"label": "time.Since",
|
|
978
|
+
"kind": 1,
|
|
979
|
+
"detail": "Duration since a time",
|
|
980
|
+
"documentation": { "value": "Returns the time elapsed since t. Shorthand for `time.Now().Sub(t)`.\n\n```go\nstart := time.Now()\n// ... work ...\nfmt.Println(\"Took:\", time.Since(start))\n```" },
|
|
981
|
+
"insertText": "time.Since(${1:start})",
|
|
982
|
+
"insertTextRules": 4,
|
|
983
|
+
"sortText": "01_time_since"
|
|
984
|
+
},
|
|
985
|
+
{
|
|
986
|
+
"label": "time.Sleep",
|
|
987
|
+
"kind": 1,
|
|
988
|
+
"detail": "Pause goroutine for duration",
|
|
989
|
+
"documentation": { "value": "Pauses the current goroutine for at least the duration d.\n\n```go\ntime.Sleep(2 * time.Second)\ntime.Sleep(100 * time.Millisecond)\n```" },
|
|
990
|
+
"insertText": "time.Sleep(${1:1} * time.${2:Second})",
|
|
991
|
+
"insertTextRules": 4,
|
|
992
|
+
"sortText": "01_time_sleep"
|
|
993
|
+
},
|
|
994
|
+
{
|
|
995
|
+
"label": "time.NewTicker",
|
|
996
|
+
"kind": 1,
|
|
997
|
+
"detail": "Create periodic ticker",
|
|
998
|
+
"documentation": { "value": "Returns a new Ticker containing a channel that sends the time at each tick.\n\n```go\nticker := time.NewTicker(1 * time.Second)\ndefer ticker.Stop()\nfor t := range ticker.C {\n fmt.Println(\"Tick at\", t)\n}\n```" },
|
|
999
|
+
"insertText": "${1:ticker} := time.NewTicker(${2:1 * time.Second})\ndefer ${1:ticker}.Stop()\n${0}",
|
|
1000
|
+
"insertTextRules": 4,
|
|
1001
|
+
"sortText": "01_time_newticker"
|
|
1002
|
+
},
|
|
1003
|
+
{
|
|
1004
|
+
"label": "time.After",
|
|
1005
|
+
"kind": 1,
|
|
1006
|
+
"detail": "Channel that fires after duration",
|
|
1007
|
+
"documentation": { "value": "Waits for the duration to elapse and then sends the current time on the returned channel.\n\n```go\nselect {\ncase <-time.After(5 * time.Second):\n fmt.Println(\"timeout\")\ncase result := <-ch:\n fmt.Println(result)\n}\n```" },
|
|
1008
|
+
"insertText": "time.After(${1:5 * time.Second})",
|
|
1009
|
+
"insertTextRules": 4,
|
|
1010
|
+
"sortText": "01_time_after"
|
|
1011
|
+
},
|
|
1012
|
+
{
|
|
1013
|
+
"label": "time.Duration",
|
|
1014
|
+
"kind": 14,
|
|
1015
|
+
"detail": "Time duration type",
|
|
1016
|
+
"documentation": { "value": "Represents elapsed time in nanoseconds. Common constants: `time.Second`, `time.Minute`, `time.Hour`, `time.Millisecond`.\n\n```go\nvar d time.Duration = 5 * time.Second\n```" },
|
|
1017
|
+
"insertText": "time.Duration",
|
|
1018
|
+
"insertTextRules": 0,
|
|
1019
|
+
"sortText": "01_time_duration"
|
|
1020
|
+
},
|
|
1021
|
+
{
|
|
1022
|
+
"label": "time.Parse",
|
|
1023
|
+
"kind": 1,
|
|
1024
|
+
"detail": "Parse time string",
|
|
1025
|
+
"documentation": { "value": "Parses a formatted string and returns the time value it represents. Go uses the reference time `Mon Jan 2 15:04:05 MST 2006`.\n\n```go\nt, err := time.Parse(time.RFC3339, \"2024-01-02T15:04:05Z\")\nt, err := time.Parse(\"2006-01-02\", \"2024-03-15\")\n```" },
|
|
1026
|
+
"insertText": "time.Parse(${1:time.RFC3339}, ${2:value})",
|
|
1027
|
+
"insertTextRules": 4,
|
|
1028
|
+
"sortText": "01_time_parse"
|
|
1029
|
+
},
|
|
1030
|
+
{
|
|
1031
|
+
"label": "time.Format",
|
|
1032
|
+
"kind": 1,
|
|
1033
|
+
"detail": "Format time to string",
|
|
1034
|
+
"documentation": { "value": "Returns a textual representation of the time value formatted according to the layout.\n\n```go\ns := t.Format(time.RFC3339)\ns := t.Format(\"2006-01-02 15:04:05\")\n```" },
|
|
1035
|
+
"insertText": "${1:t}.Format(${2:time.RFC3339})",
|
|
1036
|
+
"insertTextRules": 4,
|
|
1037
|
+
"sortText": "01_time_format"
|
|
1038
|
+
},
|
|
1039
|
+
{
|
|
1040
|
+
"label": "filepath.Join",
|
|
1041
|
+
"kind": 1,
|
|
1042
|
+
"detail": "Join path elements",
|
|
1043
|
+
"documentation": { "value": "Joins any number of path elements into a single path, adding separating slashes as needed.\n\n```go\np := filepath.Join(\"dir\", \"subdir\", \"file.txt\")\n```" },
|
|
1044
|
+
"insertText": "filepath.Join(${1:elem1}, ${2:elem2})",
|
|
1045
|
+
"insertTextRules": 4,
|
|
1046
|
+
"sortText": "01_filepath_join"
|
|
1047
|
+
},
|
|
1048
|
+
{
|
|
1049
|
+
"label": "filepath.Dir",
|
|
1050
|
+
"kind": 1,
|
|
1051
|
+
"detail": "Get directory of path",
|
|
1052
|
+
"documentation": { "value": "Returns all but the last element of path.\n\n```go\ndir := filepath.Dir(\"/foo/bar/baz.txt\") // \"/foo/bar\"\n```" },
|
|
1053
|
+
"insertText": "filepath.Dir(${1:path})",
|
|
1054
|
+
"insertTextRules": 4,
|
|
1055
|
+
"sortText": "01_filepath_dir"
|
|
1056
|
+
},
|
|
1057
|
+
{
|
|
1058
|
+
"label": "filepath.Base",
|
|
1059
|
+
"kind": 1,
|
|
1060
|
+
"detail": "Get last element of path",
|
|
1061
|
+
"documentation": { "value": "Returns the last element of path.\n\n```go\nbase := filepath.Base(\"/foo/bar/baz.txt\") // \"baz.txt\"\n```" },
|
|
1062
|
+
"insertText": "filepath.Base(${1:path})",
|
|
1063
|
+
"insertTextRules": 4,
|
|
1064
|
+
"sortText": "01_filepath_base"
|
|
1065
|
+
},
|
|
1066
|
+
{
|
|
1067
|
+
"label": "filepath.Ext",
|
|
1068
|
+
"kind": 1,
|
|
1069
|
+
"detail": "Get file extension",
|
|
1070
|
+
"documentation": { "value": "Returns the file name extension used by path.\n\n```go\next := filepath.Ext(\"file.tar.gz\") // \".gz\"\n```" },
|
|
1071
|
+
"insertText": "filepath.Ext(${1:path})",
|
|
1072
|
+
"insertTextRules": 4,
|
|
1073
|
+
"sortText": "01_filepath_ext"
|
|
1074
|
+
},
|
|
1075
|
+
{
|
|
1076
|
+
"label": "filepath.Walk",
|
|
1077
|
+
"kind": 1,
|
|
1078
|
+
"detail": "Walk a file tree",
|
|
1079
|
+
"documentation": { "value": "Walks the file tree rooted at root, calling fn for each file or directory in the tree.\n\n```go\nfilepath.Walk(\".\", func(path string, info os.FileInfo, err error) error {\n fmt.Println(path)\n return nil\n})\n```" },
|
|
1080
|
+
"insertText": "filepath.Walk(${1:root}, func(path string, info os.FileInfo, err error) error {\n\t${0}\n\treturn nil\n})",
|
|
1081
|
+
"insertTextRules": 4,
|
|
1082
|
+
"sortText": "01_filepath_walk"
|
|
1083
|
+
},
|
|
1084
|
+
{
|
|
1085
|
+
"label": "filepath.Glob",
|
|
1086
|
+
"kind": 1,
|
|
1087
|
+
"detail": "Match files with pattern",
|
|
1088
|
+
"documentation": { "value": "Returns the names of all files matching the pattern.\n\n```go\nmatches, err := filepath.Glob(\"*.go\")\n```" },
|
|
1089
|
+
"insertText": "filepath.Glob(${1:pattern})",
|
|
1090
|
+
"insertTextRules": 4,
|
|
1091
|
+
"sortText": "01_filepath_glob"
|
|
1092
|
+
},
|
|
1093
|
+
{
|
|
1094
|
+
"label": "regexp.Compile",
|
|
1095
|
+
"kind": 1,
|
|
1096
|
+
"detail": "Compile regular expression",
|
|
1097
|
+
"documentation": { "value": "Parses a regular expression and returns a Regexp object.\n\n```go\nre, err := regexp.Compile(`\\d+`)\nmatches := re.FindAllString(\"abc123def456\", -1)\n```" },
|
|
1098
|
+
"insertText": "${1:re}, ${2:err} := regexp.Compile(${3:`pattern`})",
|
|
1099
|
+
"insertTextRules": 4,
|
|
1100
|
+
"sortText": "01_regexp_compile"
|
|
1101
|
+
},
|
|
1102
|
+
{
|
|
1103
|
+
"label": "regexp.MustCompile",
|
|
1104
|
+
"kind": 1,
|
|
1105
|
+
"detail": "Compile regex or panic",
|
|
1106
|
+
"documentation": { "value": "Like `Compile` but panics if the expression cannot be parsed. Simplifies safe initialization of global variables.\n\n```go\nvar re = regexp.MustCompile(`\\d{4}-\\d{2}-\\d{2}`)\n```" },
|
|
1107
|
+
"insertText": "regexp.MustCompile(${1:`pattern`})",
|
|
1108
|
+
"insertTextRules": 4,
|
|
1109
|
+
"sortText": "01_regexp_mustcompile"
|
|
1110
|
+
},
|
|
1111
|
+
{
|
|
1112
|
+
"label": "regexp.MatchString",
|
|
1113
|
+
"kind": 1,
|
|
1114
|
+
"detail": "Check if string matches pattern",
|
|
1115
|
+
"documentation": { "value": "Reports whether the string contains any match of the regular expression pattern.\n\n```go\nok, err := regexp.MatchString(`^\\d+$`, \"12345\")\n```" },
|
|
1116
|
+
"insertText": "regexp.MatchString(${1:`pattern`}, ${2:s})",
|
|
1117
|
+
"insertTextRules": 4,
|
|
1118
|
+
"sortText": "01_regexp_matchstring"
|
|
1119
|
+
},
|
|
1120
|
+
{
|
|
1121
|
+
"label": "sort.Slice",
|
|
1122
|
+
"kind": 1,
|
|
1123
|
+
"detail": "Sort a slice",
|
|
1124
|
+
"documentation": { "value": "Sorts the slice x given the provided less function. The sort is not guaranteed to be stable.\n\n```go\nsort.Slice(people, func(i, j int) bool {\n return people[i].Age < people[j].Age\n})\n```" },
|
|
1125
|
+
"insertText": "sort.Slice(${1:slice}, func(i, j int) bool {\n\treturn ${1:slice}[i]${2:.Field} < ${1:slice}[j]${2:.Field}\n})",
|
|
1126
|
+
"insertTextRules": 4,
|
|
1127
|
+
"sortText": "01_sort_slice"
|
|
1128
|
+
},
|
|
1129
|
+
{
|
|
1130
|
+
"label": "sort.SliceStable",
|
|
1131
|
+
"kind": 1,
|
|
1132
|
+
"detail": "Stable sort a slice",
|
|
1133
|
+
"documentation": { "value": "Sorts the slice x using the provided less function, keeping equal elements in their original order.\n\n```go\nsort.SliceStable(items, func(i, j int) bool {\n return items[i].Priority < items[j].Priority\n})\n```" },
|
|
1134
|
+
"insertText": "sort.SliceStable(${1:slice}, func(i, j int) bool {\n\treturn ${1:slice}[i]${2:.Field} < ${1:slice}[j]${2:.Field}\n})",
|
|
1135
|
+
"insertTextRules": 4,
|
|
1136
|
+
"sortText": "01_sort_slicestable"
|
|
1137
|
+
},
|
|
1138
|
+
{
|
|
1139
|
+
"label": "sort.Search",
|
|
1140
|
+
"kind": 1,
|
|
1141
|
+
"detail": "Binary search in sorted data",
|
|
1142
|
+
"documentation": { "value": "Uses binary search to find the smallest index i in [0, n) at which f(i) is true.\n\n```go\ni := sort.Search(len(data), func(i int) bool {\n return data[i] >= target\n})\n```" },
|
|
1143
|
+
"insertText": "sort.Search(len(${1:data}), func(i int) bool {\n\treturn ${1:data}[i] >= ${2:target}\n})",
|
|
1144
|
+
"insertTextRules": 4,
|
|
1145
|
+
"sortText": "01_sort_search"
|
|
1146
|
+
},
|
|
1147
|
+
{
|
|
1148
|
+
"label": "log.Println",
|
|
1149
|
+
"kind": 1,
|
|
1150
|
+
"detail": "Log with newline",
|
|
1151
|
+
"documentation": { "value": "Prints to the standard logger with a timestamp prefix.\n\n```go\nlog.Println(\"Server started on :8080\")\nlog.Println(\"Request:\", r.URL.Path)\n```" },
|
|
1152
|
+
"insertText": "log.Println(${1:v})",
|
|
1153
|
+
"insertTextRules": 4,
|
|
1154
|
+
"sortText": "01_log_println"
|
|
1155
|
+
},
|
|
1156
|
+
{
|
|
1157
|
+
"label": "log.Fatal",
|
|
1158
|
+
"kind": 1,
|
|
1159
|
+
"detail": "Log and exit",
|
|
1160
|
+
"documentation": { "value": "Equivalent to `Println()` followed by a call to `os.Exit(1)`.\n\n```go\nlog.Fatal(err)\nlog.Fatal(\"Could not start server\")\n```" },
|
|
1161
|
+
"insertText": "log.Fatal(${1:v})",
|
|
1162
|
+
"insertTextRules": 4,
|
|
1163
|
+
"sortText": "01_log_fatal"
|
|
1164
|
+
},
|
|
1165
|
+
{
|
|
1166
|
+
"label": "log.Printf",
|
|
1167
|
+
"kind": 1,
|
|
1168
|
+
"detail": "Formatted log",
|
|
1169
|
+
"documentation": { "value": "Calls `fmt.Sprintf` to format and then prints to the standard logger.\n\n```go\nlog.Printf(\"Listening on port %d\", port)\n```" },
|
|
1170
|
+
"insertText": "log.Printf(\"${1:%v}\", ${2:v})",
|
|
1171
|
+
"insertTextRules": 4,
|
|
1172
|
+
"sortText": "01_log_printf"
|
|
1173
|
+
},
|
|
1174
|
+
{
|
|
1175
|
+
"label": "bytes.Buffer",
|
|
1176
|
+
"kind": 21,
|
|
1177
|
+
"detail": "Variable-size byte buffer",
|
|
1178
|
+
"documentation": { "value": "A Buffer is a variable-sized buffer of bytes with `Read` and `Write` methods.\n\n```go\nvar buf bytes.Buffer\nbuf.WriteString(\"hello\")\nbuf.Write([]byte(\" world\"))\nfmt.Println(buf.String())\n```" },
|
|
1179
|
+
"insertText": "var ${1:buf} bytes.Buffer\n${1:buf}.WriteString(${2:s})\n${0}",
|
|
1180
|
+
"insertTextRules": 4,
|
|
1181
|
+
"sortText": "01_bytes_buffer"
|
|
1182
|
+
},
|
|
1183
|
+
{
|
|
1184
|
+
"label": "bytes.NewReader",
|
|
1185
|
+
"kind": 1,
|
|
1186
|
+
"detail": "Create reader from bytes",
|
|
1187
|
+
"documentation": { "value": "Returns a new Reader reading from b.\n\n```go\nr := bytes.NewReader([]byte(\"hello\"))\n```" },
|
|
1188
|
+
"insertText": "bytes.NewReader(${1:b})",
|
|
1189
|
+
"insertTextRules": 4,
|
|
1190
|
+
"sortText": "01_bytes_newreader"
|
|
1191
|
+
},
|
|
1192
|
+
{
|
|
1193
|
+
"label": "bytes.Contains",
|
|
1194
|
+
"kind": 1,
|
|
1195
|
+
"detail": "Check if bytes contains subslice",
|
|
1196
|
+
"documentation": { "value": "Reports whether subslice is within b.\n\n```go\nbytes.Contains([]byte(\"seafood\"), []byte(\"foo\")) // true\n```" },
|
|
1197
|
+
"insertText": "bytes.Contains(${1:b}, ${2:subslice})",
|
|
1198
|
+
"insertTextRules": 4,
|
|
1199
|
+
"sortText": "01_bytes_contains"
|
|
1200
|
+
},
|
|
1201
|
+
{
|
|
1202
|
+
"label": "bufio.NewReader",
|
|
1203
|
+
"kind": 1,
|
|
1204
|
+
"detail": "Create buffered reader",
|
|
1205
|
+
"documentation": { "value": "Returns a new Reader whose buffer has the default size.\n\n```go\nreader := bufio.NewReader(os.Stdin)\nline, _ := reader.ReadString('\\n')\n```" },
|
|
1206
|
+
"insertText": "bufio.NewReader(${1:r})",
|
|
1207
|
+
"insertTextRules": 4,
|
|
1208
|
+
"sortText": "01_bufio_newreader"
|
|
1209
|
+
},
|
|
1210
|
+
{
|
|
1211
|
+
"label": "bufio.NewScanner",
|
|
1212
|
+
"kind": 1,
|
|
1213
|
+
"detail": "Create line scanner",
|
|
1214
|
+
"documentation": { "value": "Returns a new Scanner to read from r. Default split function is `ScanLines`.\n\n```go\nscanner := bufio.NewScanner(f)\nfor scanner.Scan() {\n fmt.Println(scanner.Text())\n}\nif err := scanner.Err(); err != nil {\n log.Fatal(err)\n}\n```" },
|
|
1215
|
+
"insertText": "${1:scanner} := bufio.NewScanner(${2:r})\nfor ${1:scanner}.Scan() {\n\t${3:fmt.Println(${1:scanner}.Text())}\n}\n${0}",
|
|
1216
|
+
"insertTextRules": 4,
|
|
1217
|
+
"sortText": "01_bufio_newscanner"
|
|
1218
|
+
},
|
|
1219
|
+
{
|
|
1220
|
+
"label": "bufio.NewWriter",
|
|
1221
|
+
"kind": 1,
|
|
1222
|
+
"detail": "Create buffered writer",
|
|
1223
|
+
"documentation": { "value": "Returns a new Writer whose buffer has the default size.\n\n```go\nw := bufio.NewWriter(f)\nw.WriteString(\"hello\\n\")\nw.Flush()\n```" },
|
|
1224
|
+
"insertText": "${1:w} := bufio.NewWriter(${2:f})\n${0}\n${1:w}.Flush()",
|
|
1225
|
+
"insertTextRules": 4,
|
|
1226
|
+
"sortText": "01_bufio_newwriter"
|
|
1227
|
+
},
|
|
1228
|
+
{
|
|
1229
|
+
"label": "maps.Keys",
|
|
1230
|
+
"kind": 1,
|
|
1231
|
+
"detail": "Return map keys (Go 1.21+)",
|
|
1232
|
+
"documentation": { "value": "Returns the keys of the map m. The keys are returned in no particular order.\n\n```go\nkeys := maps.Keys(m)\n```" },
|
|
1233
|
+
"insertText": "maps.Keys(${1:m})",
|
|
1234
|
+
"insertTextRules": 4,
|
|
1235
|
+
"sortText": "01_maps_keys"
|
|
1236
|
+
},
|
|
1237
|
+
{
|
|
1238
|
+
"label": "maps.Values",
|
|
1239
|
+
"kind": 1,
|
|
1240
|
+
"detail": "Return map values (Go 1.21+)",
|
|
1241
|
+
"documentation": { "value": "Returns the values of the map m.\n\n```go\nvals := maps.Values(m)\n```" },
|
|
1242
|
+
"insertText": "maps.Values(${1:m})",
|
|
1243
|
+
"insertTextRules": 4,
|
|
1244
|
+
"sortText": "01_maps_values"
|
|
1245
|
+
},
|
|
1246
|
+
{
|
|
1247
|
+
"label": "maps.Clone",
|
|
1248
|
+
"kind": 1,
|
|
1249
|
+
"detail": "Clone a map (Go 1.21+)",
|
|
1250
|
+
"documentation": { "value": "Returns a copy of m. The elements are copied using assignment.\n\n```go\nm2 := maps.Clone(m)\n```" },
|
|
1251
|
+
"insertText": "maps.Clone(${1:m})",
|
|
1252
|
+
"insertTextRules": 4,
|
|
1253
|
+
"sortText": "01_maps_clone"
|
|
1254
|
+
},
|
|
1255
|
+
{
|
|
1256
|
+
"label": "slices.Sort",
|
|
1257
|
+
"kind": 1,
|
|
1258
|
+
"detail": "Sort a slice (Go 1.21+)",
|
|
1259
|
+
"documentation": { "value": "Sorts a slice of any ordered type in ascending order.\n\n```go\nslices.Sort([]int{3, 1, 2}) // [1, 2, 3]\n```" },
|
|
1260
|
+
"insertText": "slices.Sort(${1:s})",
|
|
1261
|
+
"insertTextRules": 4,
|
|
1262
|
+
"sortText": "01_slices_sort"
|
|
1263
|
+
},
|
|
1264
|
+
{
|
|
1265
|
+
"label": "slices.Contains",
|
|
1266
|
+
"kind": 1,
|
|
1267
|
+
"detail": "Check if slice contains value (Go 1.21+)",
|
|
1268
|
+
"documentation": { "value": "Reports whether v is present in s.\n\n```go\nslices.Contains([]string{\"a\", \"b\"}, \"a\") // true\n```" },
|
|
1269
|
+
"insertText": "slices.Contains(${1:s}, ${2:v})",
|
|
1270
|
+
"insertTextRules": 4,
|
|
1271
|
+
"sortText": "01_slices_contains"
|
|
1272
|
+
},
|
|
1273
|
+
{
|
|
1274
|
+
"label": "slices.Index",
|
|
1275
|
+
"kind": 1,
|
|
1276
|
+
"detail": "Find index of value in slice (Go 1.21+)",
|
|
1277
|
+
"documentation": { "value": "Returns the index of the first occurrence of v in s, or -1 if not present.\n\n```go\ni := slices.Index(names, \"Alice\")\n```" },
|
|
1278
|
+
"insertText": "slices.Index(${1:s}, ${2:v})",
|
|
1279
|
+
"insertTextRules": 4,
|
|
1280
|
+
"sortText": "01_slices_index"
|
|
1281
|
+
},
|
|
1282
|
+
{
|
|
1283
|
+
"label": "slices.Compact",
|
|
1284
|
+
"kind": 1,
|
|
1285
|
+
"detail": "Remove consecutive duplicates (Go 1.21+)",
|
|
1286
|
+
"documentation": { "value": "Replaces consecutive runs of equal elements with a single copy. Like `uniq` on a sorted slice.\n\n```go\ns := slices.Compact([]int{1, 1, 2, 3, 3}) // [1, 2, 3]\n```" },
|
|
1287
|
+
"insertText": "slices.Compact(${1:s})",
|
|
1288
|
+
"insertTextRules": 4,
|
|
1289
|
+
"sortText": "01_slices_compact"
|
|
1290
|
+
},
|
|
1291
|
+
{
|
|
1292
|
+
"label": "slices.SortFunc",
|
|
1293
|
+
"kind": 1,
|
|
1294
|
+
"detail": "Sort with custom comparison (Go 1.21+)",
|
|
1295
|
+
"documentation": { "value": "Sorts the slice s in ascending order as determined by the cmp function.\n\n```go\nslices.SortFunc(people, func(a, b Person) int {\n return cmp.Compare(a.Age, b.Age)\n})\n```" },
|
|
1296
|
+
"insertText": "slices.SortFunc(${1:s}, func(a, b ${2:Type}) int {\n\treturn ${3:cmp.Compare(a, b)}\n})",
|
|
1297
|
+
"insertTextRules": 4,
|
|
1298
|
+
"sortText": "01_slices_sortfunc"
|
|
1299
|
+
},
|
|
1300
|
+
{
|
|
1301
|
+
"label": "slog.Info",
|
|
1302
|
+
"kind": 1,
|
|
1303
|
+
"detail": "Log info message (Go 1.21+)",
|
|
1304
|
+
"documentation": { "value": "Logs at INFO level using the default logger.\n\n```go\nslog.Info(\"request handled\", \"method\", r.Method, \"path\", r.URL.Path)\nslog.Info(\"server started\", \"port\", port)\n```" },
|
|
1305
|
+
"insertText": "slog.Info(\"${1:message}\", ${2:\"key\"}, ${3:value})",
|
|
1306
|
+
"insertTextRules": 4,
|
|
1307
|
+
"sortText": "01_slog_info"
|
|
1308
|
+
},
|
|
1309
|
+
{
|
|
1310
|
+
"label": "slog.Error",
|
|
1311
|
+
"kind": 1,
|
|
1312
|
+
"detail": "Log error message (Go 1.21+)",
|
|
1313
|
+
"documentation": { "value": "Logs at ERROR level using the default logger.\n\n```go\nslog.Error(\"failed to process\", \"err\", err, \"id\", id)\n```" },
|
|
1314
|
+
"insertText": "slog.Error(\"${1:message}\", ${2:\"err\"}, ${3:err})",
|
|
1315
|
+
"insertTextRules": 4,
|
|
1316
|
+
"sortText": "01_slog_error"
|
|
1317
|
+
},
|
|
1318
|
+
{
|
|
1319
|
+
"label": "slog.Debug",
|
|
1320
|
+
"kind": 1,
|
|
1321
|
+
"detail": "Log debug message (Go 1.21+)",
|
|
1322
|
+
"documentation": { "value": "Logs at DEBUG level using the default logger.\n\n```go\nslog.Debug(\"processing item\", \"id\", id)\n```" },
|
|
1323
|
+
"insertText": "slog.Debug(\"${1:message}\", ${2:\"key\"}, ${3:value})",
|
|
1324
|
+
"insertTextRules": 4,
|
|
1325
|
+
"sortText": "01_slog_debug"
|
|
1326
|
+
},
|
|
1327
|
+
{
|
|
1328
|
+
"label": "slog.Warn",
|
|
1329
|
+
"kind": 1,
|
|
1330
|
+
"detail": "Log warning message (Go 1.21+)",
|
|
1331
|
+
"documentation": { "value": "Logs at WARN level using the default logger.\n\n```go\nslog.Warn(\"deprecated endpoint used\", \"path\", r.URL.Path)\n```" },
|
|
1332
|
+
"insertText": "slog.Warn(\"${1:message}\", ${2:\"key\"}, ${3:value})",
|
|
1333
|
+
"insertTextRules": 4,
|
|
1334
|
+
"sortText": "01_slog_warn"
|
|
1335
|
+
},
|
|
1336
|
+
{
|
|
1337
|
+
"label": "slog.With",
|
|
1338
|
+
"kind": 1,
|
|
1339
|
+
"detail": "Create logger with default attributes (Go 1.21+)",
|
|
1340
|
+
"documentation": { "value": "Returns a Logger that includes the given attributes in each output operation.\n\n```go\nlogger := slog.With(\"request_id\", reqID)\nlogger.Info(\"handling request\")\n```" },
|
|
1341
|
+
"insertText": "slog.With(${1:\"key\"}, ${2:value})",
|
|
1342
|
+
"insertTextRules": 4,
|
|
1343
|
+
"sortText": "01_slog_with"
|
|
1344
|
+
}
|
|
1345
|
+
]
|
|
1346
|
+
}
|