diff options
author | NeonXP <i@neonxp.dev> | 2023-08-06 01:23:45 +0300 |
---|---|---|
committer | NeonXP <i@neonxp.dev> | 2023-08-06 01:29:52 +0300 |
commit | e8563a5e6f431fb953ad738262b5150b8349582d (patch) | |
tree | 519f07c34a79d8f48ca5a2682e08ccb04f5d1b7c /snippets/snippets.json | |
parent | 7818c08dc67c6916956c50e93e01e0a04010898b (diff) |
fix if err... code action
Diffstat (limited to 'snippets/snippets.json')
-rw-r--r-- | snippets/snippets.json | 32 |
1 files changed, 6 insertions, 26 deletions
diff --git a/snippets/snippets.json b/snippets/snippets.json index 456a661..91f898d 100644 --- a/snippets/snippets.json +++ b/snippets/snippets.json @@ -1,5 +1,5 @@ { - "Package line": { + "package line": { "body": [ "package ${TM_DIRECTORY/.+\\/(.+)$/${1:/downcase}/}", "", @@ -8,27 +8,7 @@ "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": { + "structure constructor": { "body": [ "// New$1 returns new $1.", "func New${1:type}(${2}) *$1 {", @@ -39,9 +19,9 @@ "description": "constructor for structure type", "prefix": "construct" }, - "Variable declaration": { - "body": "var $1 $2 = $3", - "description": "variable with type and value", - "prefix": "var" + "if err := ...; err != nil": { + "prefix": "iferr", + "body": "if err := ${1}; err != nil {\n\t${2:return ${3:nil, }${4:err}}\n}", + "description": "Snippet for if err := ...; err != nil" } } |