2018-09-30 20:58:57 +00:00
|
|
|
snippet v "shorthand variable declaration"
|
2013-11-16 19:45:48 +00:00
|
|
|
${1} := ${2}
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet vr "variable initialization"
|
2013-11-16 19:45:48 +00:00
|
|
|
var ${1:t} ${0:string}
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet var "variable declaration"
|
2013-11-16 19:45:48 +00:00
|
|
|
var ${1} ${2} = ${3}
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet vars "variables declaration"
|
2013-11-16 19:45:48 +00:00
|
|
|
var (
|
|
|
|
${1} ${2} = ${3}
|
|
|
|
)
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet ap "append"
|
2013-11-16 19:45:48 +00:00
|
|
|
append(${1:slice}, ${0:value})
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet bl "bool"
|
2012-08-17 03:41:25 +00:00
|
|
|
bool
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet bt "byte"
|
2012-08-17 03:41:25 +00:00
|
|
|
byte
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet br "break"
|
2012-08-17 03:41:25 +00:00
|
|
|
break
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet ch "channel"
|
2013-11-16 19:45:48 +00:00
|
|
|
chan ${0:int}
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet cs "case"
|
2012-08-17 03:41:25 +00:00
|
|
|
case ${1:value}:
|
2017-02-11 13:01:38 +00:00
|
|
|
${0:${VISUAL}}
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet c "const"
|
2013-11-16 19:45:48 +00:00
|
|
|
const ${1:NAME} = ${0:0}
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet co "constants with iota"
|
2012-08-17 03:41:25 +00:00
|
|
|
const (
|
|
|
|
${1:NAME1} = iota
|
2013-11-16 19:45:48 +00:00
|
|
|
${0:NAME2}
|
2012-08-17 03:41:25 +00:00
|
|
|
)
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet cn "continue"
|
2012-08-17 03:41:25 +00:00
|
|
|
continue
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet df "defer"
|
2013-11-16 19:45:48 +00:00
|
|
|
defer ${0:func}()
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet dfr "defer recover"
|
2012-08-17 03:41:25 +00:00
|
|
|
defer func() {
|
|
|
|
if err := recover(); err != nil {
|
2017-02-11 13:01:38 +00:00
|
|
|
${0:${VISUAL}}
|
2012-08-17 03:41:25 +00:00
|
|
|
}
|
|
|
|
}()
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet i "int"
|
2012-08-17 03:41:25 +00:00
|
|
|
int
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet im "import"
|
2012-08-17 03:41:25 +00:00
|
|
|
import (
|
2013-07-17 23:06:05 +00:00
|
|
|
"${1:package}"
|
2013-11-16 19:45:48 +00:00
|
|
|
)
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet in "interface"
|
2012-08-17 03:41:25 +00:00
|
|
|
interface{}
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet inf "full interface "
|
2012-08-17 03:41:25 +00:00
|
|
|
interface ${1:name} {
|
|
|
|
${2:/* methods */}
|
2013-11-16 19:45:48 +00:00
|
|
|
}
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet if "if condition"
|
2012-08-17 03:41:25 +00:00
|
|
|
if ${1:/* condition */} {
|
2017-02-11 13:01:38 +00:00
|
|
|
${2:${VISUAL}}
|
2013-11-16 19:45:48 +00:00
|
|
|
}
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
snippet ife "if else condition"
|
2016-03-14 10:04:57 +00:00
|
|
|
if ${1:/* condition */} {
|
2017-02-11 13:01:38 +00:00
|
|
|
${2:${VISUAL}}
|
2016-03-14 10:04:57 +00:00
|
|
|
} else {
|
|
|
|
${0}
|
|
|
|
}
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet el "else"
|
2012-08-17 03:41:25 +00:00
|
|
|
else {
|
2017-02-11 13:01:38 +00:00
|
|
|
${0:${VISUAL}}
|
2013-11-16 19:45:48 +00:00
|
|
|
}
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet ir "if error not nil, return err"
|
2012-08-17 03:41:25 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2013-11-16 19:45:48 +00:00
|
|
|
${0}
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet f "false"
|
2012-08-17 03:41:25 +00:00
|
|
|
false
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet ft "fallthrough"
|
2012-08-17 03:41:25 +00:00
|
|
|
fallthrough
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet fl "float"
|
2012-08-17 03:41:25 +00:00
|
|
|
float32
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet f3 "float32"
|
2012-08-17 03:41:25 +00:00
|
|
|
float32
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet f6 "float64"
|
2012-08-17 03:41:25 +00:00
|
|
|
float64
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet for "for loop"
|
2016-03-14 10:04:57 +00:00
|
|
|
for ${1}{
|
2017-02-11 13:01:38 +00:00
|
|
|
${0:${VISUAL}}
|
2016-03-14 10:04:57 +00:00
|
|
|
}
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet fori "for int loop"
|
2013-04-13 17:45:21 +00:00
|
|
|
for ${2:i} := 0; $2 < ${1:count}; $2${3:++} {
|
2017-02-11 13:01:38 +00:00
|
|
|
${0:${VISUAL}}
|
2012-08-17 03:41:25 +00:00
|
|
|
}
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet forr "for range loop"
|
2016-03-14 10:04:57 +00:00
|
|
|
for ${1:e} := range ${2:collection} {
|
2017-02-11 13:01:38 +00:00
|
|
|
${0:${VISUAL}}
|
2012-08-17 03:41:25 +00:00
|
|
|
}
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet fun "function"
|
2013-04-13 17:45:21 +00:00
|
|
|
func ${1:funcName}(${2}) ${3:error} {
|
2013-07-17 23:06:05 +00:00
|
|
|
${4}
|
2012-08-17 03:41:25 +00:00
|
|
|
}
|
2013-11-16 19:45:48 +00:00
|
|
|
${0}
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet fum "method"
|
2015-01-18 12:58:28 +00:00
|
|
|
func (${1:receiver} ${2:type}) ${3:funcName}(${4}) ${5:error} {
|
|
|
|
${6}
|
2012-08-17 03:41:25 +00:00
|
|
|
}
|
2013-11-16 19:45:48 +00:00
|
|
|
${0}
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet fumh "http handler function on reciever"
|
2018-06-14 10:31:12 +00:00
|
|
|
func (${1:receiver} ${2:type}) ${3:funcName}(${4:w} http.ResponseWriter, ${5:r} *http.Request) {
|
|
|
|
${0:${VISUAL}}
|
|
|
|
}
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet lf "log printf"
|
2013-11-16 19:45:48 +00:00
|
|
|
log.Printf("%${1:s}", ${2:var})
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet lp "log println"
|
2013-11-16 19:45:48 +00:00
|
|
|
log.Println("${1}")
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet mk "make"
|
2013-11-16 19:45:48 +00:00
|
|
|
make(${1:[]string}, ${0:0})
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet mp "map"
|
2013-11-16 19:45:48 +00:00
|
|
|
map[${1:string}]${0:int}
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet main "func main()"
|
2012-08-17 03:41:25 +00:00
|
|
|
func main() {
|
2013-07-17 23:06:05 +00:00
|
|
|
${1}
|
2012-08-17 03:41:25 +00:00
|
|
|
}
|
2013-11-16 19:45:48 +00:00
|
|
|
${0}
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet nw "new"
|
2013-11-16 19:45:48 +00:00
|
|
|
new(${0:type})
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet pa "package"
|
2015-01-18 12:58:28 +00:00
|
|
|
package ${1:main}
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet pn "panic"
|
2013-11-16 19:45:48 +00:00
|
|
|
panic("${0:msg}")
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet pf "fmt.Printf()"
|
2013-11-16 19:45:48 +00:00
|
|
|
fmt.Printf("%${1:s}\n", ${2:var})
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet pl "fmt.Println()"
|
2016-08-02 12:48:32 +00:00
|
|
|
fmt.Println("${1:s}")
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet rn "range"
|
2013-11-16 19:45:48 +00:00
|
|
|
range ${0}
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet rt "return"
|
2013-11-16 19:45:48 +00:00
|
|
|
return ${0}
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet rs "result"
|
2012-08-17 03:41:25 +00:00
|
|
|
result
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet sl "select"
|
2012-08-17 03:41:25 +00:00
|
|
|
select {
|
|
|
|
case ${1:v1} := <-${2:chan1}
|
2013-07-17 23:06:05 +00:00
|
|
|
${3}
|
2012-08-17 03:41:25 +00:00
|
|
|
default:
|
2013-11-16 19:45:48 +00:00
|
|
|
${0}
|
2012-08-17 03:41:25 +00:00
|
|
|
}
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet sr "string"
|
2012-08-17 03:41:25 +00:00
|
|
|
string
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet st "struct"
|
2012-08-17 03:41:25 +00:00
|
|
|
struct ${1:name} {
|
|
|
|
${2:/* data */}
|
2013-04-13 17:45:21 +00:00
|
|
|
}
|
2013-11-16 19:45:48 +00:00
|
|
|
${0}
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet sw "switch"
|
2012-08-17 03:41:25 +00:00
|
|
|
switch ${1:var} {
|
|
|
|
case ${2:value1}:
|
2013-07-17 23:06:05 +00:00
|
|
|
${3}
|
2012-08-17 03:41:25 +00:00
|
|
|
case ${4:value2}:
|
2013-07-17 23:06:05 +00:00
|
|
|
${5}
|
2012-08-17 03:41:25 +00:00
|
|
|
default:
|
2013-11-16 19:45:48 +00:00
|
|
|
${0}
|
2012-08-17 03:41:25 +00:00
|
|
|
}
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet ps "fmt.Sprintf"
|
2013-11-16 19:45:48 +00:00
|
|
|
fmt.Sprintf("%${1:s}", ${2:var})
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet t "true"
|
2012-08-17 03:41:25 +00:00
|
|
|
true
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet g "goroutine named function"
|
2013-11-16 19:45:48 +00:00
|
|
|
go ${1:funcName}(${0})
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet ga "goroutine anonymous function"
|
2013-08-03 12:50:12 +00:00
|
|
|
go func(${1} ${2:type}) {
|
|
|
|
${3:/* code */}
|
2013-11-16 19:45:48 +00:00
|
|
|
}(${0})
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet test "test function"
|
2014-07-02 11:18:18 +00:00
|
|
|
func Test${1:name}(t *testing.T) {
|
2017-02-11 13:01:38 +00:00
|
|
|
${0:${VISUAL}}
|
2014-07-02 11:18:18 +00:00
|
|
|
}
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet bench "benchmark function"
|
2014-07-02 11:18:18 +00:00
|
|
|
func Benchmark${1:name}(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
${2}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
${0}
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet cl "composite literals"
|
2017-07-06 12:57:35 +00:00
|
|
|
type ${1:name} struct {
|
|
|
|
${2:attrName} ${3:attrType}
|
|
|
|
}
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet om "if key in a map"
|
2017-07-06 12:57:35 +00:00
|
|
|
if ${1:value}, ok := ${2:map}[${3:key}]; ok == true {
|
|
|
|
${4:/* code */}
|
|
|
|
}
|
|
|
|
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet gg "Grouped globals with anonymous struct"
|
2017-07-06 12:57:35 +00:00
|
|
|
var ${1:var} = struct{
|
|
|
|
${2:name} ${3:type}
|
|
|
|
}{
|
|
|
|
$2: ${4:value},
|
|
|
|
}
|
|
|
|
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet ja "Marshalable json alias"
|
2017-07-06 12:57:35 +00:00
|
|
|
type ${1:parentType}Alias $1
|
|
|
|
|
|
|
|
func (p *$1) MarshalJSON() ([]byte, error) {
|
|
|
|
return json.Marshal(&struct{ *$1Alias }{(*$1Alias)(p)})
|
|
|
|
}
|
2018-09-25 00:40:17 +00:00
|
|
|
|
2018-09-30 20:58:57 +00:00
|
|
|
|
|
|
|
snippet errwr "Error handling with errors.Wrap"
|
2018-09-25 00:40:17 +00:00
|
|
|
if ${1}err != nil {
|
|
|
|
return errors.Wrap(err, "${2}")
|
|
|
|
}
|