47 lines
1.2 KiB
JSON
47 lines
1.2 KiB
JSON
{
|
|
"Package line": {
|
|
"body": [
|
|
"package ${TM_DIRECTORY/.+\\/(.+)$/${1:/downcase}/}",
|
|
"",
|
|
"$0"
|
|
],
|
|
"description": "package header",
|
|
"prefix": "pkg"
|
|
},
|
|
"Stack from array": {
|
|
"body": [
|
|
"type ${1:name} []${2:type}",
|
|
"",
|
|
"func (s *$1) Push(item $2) {",
|
|
"\t*s = append(*s, item)",
|
|
"}",
|
|
"",
|
|
"func (s *$1) Pop() (item $2) {",
|
|
"\tif len(*s) == 0 {",
|
|
"\t\treturn",
|
|
"\t}",
|
|
"",
|
|
"\t*s, item = (*s)[:len(*s)-1], (*s)[len(*s)-1]",
|
|
"\treturn item",
|
|
"}"
|
|
],
|
|
"description": "stack from array type",
|
|
"prefix": "stack"
|
|
},
|
|
"Structure constructor": {
|
|
"body": [
|
|
"// New$1 returns new $1.",
|
|
"func New${1:type}(${2}) *$1 {",
|
|
"\t$3",
|
|
"\treturn &$1{$4}",
|
|
"}"
|
|
],
|
|
"description": "constructor for structure type",
|
|
"prefix": "construct"
|
|
},
|
|
"Variable declaration": {
|
|
"body": "var $1 $2 = $3",
|
|
"description": "variable with type and value",
|
|
"prefix": "var"
|
|
}
|
|
}
|