-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgo.json
More file actions
133 lines (122 loc) · 2.96 KB
/
go.json
File metadata and controls
133 lines (122 loc) · 2.96 KB
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
{
// Place your snippets for go here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
// "$2"
// ],
// "description": "Log output to console"
// }
"Create main": {
"prefix": "gomain",
"body": [
"package main",
"",
"func main(){",
"$0",
"}"
],
"description": "Create main basic structure"
},
"Test : If expected != got": {
"prefix": "testif",
"body": [
"if expected, got := ${1:expectedValue}, ${2:gotValue}; expected != got {",
" t.Errorf(\"$3. Expected: %v but got: %v\", expected, got)",
"}"
],
"description": "Create test if statement to compare expected value versus got values"
},
"if - else": {
"prefix": "ifel",
"body": [
"if ${1:condition} {",
" $0",
"} else {",
"}"
],
"description": "Create test if statement to compare expected value versus got values"
},
"struct": {
"prefix": "struct",
"body": [
"type ${1:name} struct {",
" $0",
"}"
],
"description": "Create a struct"
},
"interface": {
"prefix": "interface",
"body": [
"type ${1:name} interface {",
" $0",
"}"
],
"description": "Create an interface"
},
"fmt.Println": {
"prefix": "pln",
"body": [
"fmt.Println(\"$0\")"
],
"description": "Printline with quotation marks "
},
"Call method returning error. Return error if not nil": {
"prefix": "calle",
"body": [
"${1:value}, ${2:error} := ${3:expression}",
"if $2 != nil {",
" return ${4:valueOnError}, $2",
"}",
"$0"
],
"description": "Call method returning error. If error, return it"
},
"Declare new channel": {
"prefix": "mch",
"body": [
"${1:channelName} := make(chan ${2:channelType})"
],
"description": "Call method returning error. If error, return new error"
},
"Wait group waiting for channel": {
"prefix": "wgc",
"body": [
"${1:channelName} := make(chan ${2:channelType})",
"${3:waitGroupName} := sync.WaitGroup{}",
"",
"for ${4:loopCondition} {",
" $3.Add(1)",
" go ${5:goRoutineWritingToChannel}(${6:otherFuncParameters}, $1)",
"}",
"",
"go func() {",
" for ${7:result} := range $1 {",
" ${8:functionToDoActionsWithResults} ($7)",
" $3.Done()",
" }",
"}()",
"",
"$3.Wait()",
"close($1)"
],
"description": "WaitGroup that wais for channel to finish receiving data"
},
"Timer": {
"prefix": "tmr",
"body": [
"${1:start} := time.Now()",
"",
"$0",
"",
"${2:elapsed} := time.Since($1)",
],
"description": "Call method returning error. If error, return new error"
}
}