Merge pull request #171 from farslan/issue-171
Add and improve golang snippets
This commit is contained in:
commit
7101cf3be7
@ -67,7 +67,7 @@ snippet i
|
|||||||
snippet im
|
snippet im
|
||||||
import (
|
import (
|
||||||
"${1:package}"
|
"${1:package}"
|
||||||
)
|
)${2}
|
||||||
# interface
|
# interface
|
||||||
snippet in
|
snippet in
|
||||||
interface{}
|
interface{}
|
||||||
@ -80,12 +80,12 @@ snippet inf
|
|||||||
snippet if
|
snippet if
|
||||||
if ${1:/* condition */} {
|
if ${1:/* condition */} {
|
||||||
${2:/* code */}
|
${2:/* code */}
|
||||||
}
|
}${2}
|
||||||
# else snippet
|
# else snippet
|
||||||
snippet el
|
snippet el
|
||||||
else {
|
else {
|
||||||
${1}
|
${1}
|
||||||
}
|
}${2}
|
||||||
# error snippet
|
# error snippet
|
||||||
snippet ir
|
snippet ir
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -114,26 +114,37 @@ snippet ie
|
|||||||
} else {
|
} else {
|
||||||
${3}
|
${3}
|
||||||
}
|
}
|
||||||
|
${4}
|
||||||
# for loop
|
# for loop
|
||||||
snippet fo
|
snippet fo
|
||||||
for ${2:i} = 0; $2 < ${1:count}; $2${3:++} {
|
for ${2:i} = 0; $2 < ${1:count}; $2${3:++} {
|
||||||
${4:/* code */}
|
${4:/* code */}
|
||||||
}
|
}
|
||||||
|
${5}
|
||||||
# for range loop
|
# for range loop
|
||||||
snippet fr
|
snippet fr
|
||||||
for ${1:k}, ${2:v} := range ${3} {
|
for ${1:k}, ${2:v} := range ${3} {
|
||||||
${4:/* code */}
|
${4:/* code */}
|
||||||
}
|
}
|
||||||
|
${5}
|
||||||
# function simple
|
# function simple
|
||||||
snippet fun
|
snippet fun
|
||||||
func ${1:funcName}(${2}) ${3:error} {
|
func ${1:funcName}(${2}) ${3:error} {
|
||||||
${4:/* code */}
|
${4:/* code */}
|
||||||
}
|
}
|
||||||
|
${5}
|
||||||
# function on receiver
|
# function on receiver
|
||||||
snippet fum
|
snippet fum
|
||||||
func (self ${1:type}) ${2:funcName}(${3}) ${4:error} {
|
func (self ${1:type}) ${2:funcName}(${3}) ${4:error} {
|
||||||
${5:/* code */}
|
${5:/* code */}
|
||||||
}
|
}
|
||||||
|
${6}
|
||||||
|
# log printf
|
||||||
|
snippet lf
|
||||||
|
log.Printf("%${1:s}", ${2:var})${3}
|
||||||
|
# log printf
|
||||||
|
snippet lp
|
||||||
|
log.Println("${1}")${2}
|
||||||
# make
|
# make
|
||||||
snippet mk
|
snippet mk
|
||||||
make(${1:[]string}, ${2:0})
|
make(${1:[]string}, ${2:0})
|
||||||
@ -145,6 +156,7 @@ snippet main
|
|||||||
func main() {
|
func main() {
|
||||||
${1:/* code */}
|
${1:/* code */}
|
||||||
}
|
}
|
||||||
|
${2}
|
||||||
# new
|
# new
|
||||||
snippet nw
|
snippet nw
|
||||||
new(${1:type})
|
new(${1:type})
|
||||||
@ -153,7 +165,7 @@ snippet pn
|
|||||||
panic("${1:msg}")
|
panic("${1:msg}")
|
||||||
# print
|
# print
|
||||||
snippet pr
|
snippet pr
|
||||||
fmt.Printf("${1:%s}\n", ${2:var})${3}
|
fmt.Printf("%${1:s}\n", ${2:var})${3}
|
||||||
# range
|
# range
|
||||||
snippet rn
|
snippet rn
|
||||||
range ${1}
|
range ${1}
|
||||||
@ -180,7 +192,8 @@ snippet sr
|
|||||||
snippet st
|
snippet st
|
||||||
struct ${1:name} {
|
struct ${1:name} {
|
||||||
${2:/* data */}
|
${2:/* data */}
|
||||||
}${4}
|
}
|
||||||
|
${3}
|
||||||
# switch
|
# switch
|
||||||
snippet sw
|
snippet sw
|
||||||
switch ${1:var} {
|
switch ${1:var} {
|
||||||
@ -192,7 +205,7 @@ snippet sw
|
|||||||
${6:/* code */}
|
${6:/* code */}
|
||||||
}
|
}
|
||||||
snippet sp
|
snippet sp
|
||||||
fmt.Sprintf("${1:%s}", ${2:var})${3}
|
fmt.Sprintf("%${1:s}", ${2:var})${3}
|
||||||
# true
|
# true
|
||||||
snippet t
|
snippet t
|
||||||
true
|
true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user