form: https://github.com/Microsoft/vscode-go
"snippets": [],
"default_snippets": [ { "match": {"global": false,"pkgname": ""},"snippets": [ {"text": "package ${default_pkgname}","title": "","value": "package ${default_pkgname}\n\n$1\n"} ] },{ "match": {"global": true,"pkgname": "^main$"},"snippets": [ {"text": "func main","title": "func main {...}","value": "func main() {\n\t$0\n}\n"} ] },"pkgname": "."},"snippets": [ {"text": "import","title": "import (...)","value": "import (\n\t\"$1\"\n)"},{"text": "func","title": "func {...}","value": "func ${1:name}($2)$3 {\n\t$0\n}"},{"text": "var","title": "var (...)","value": "var (\n\t$1\n)"},{"text": "const","title": "const (...)","value": "const (\n\t$1\n)"},{"text": "init","title": "func init()","value": "func init() {\n\t$1\n}"},{ "text": "func http handler","title": "func(rw,req)","value": "func ${1:name}(rw http.ResponseWriter,req *http.Request) {\n\t$0\n}" } ] },"pkgname": ".","has_types": true},"snippets": [ { "text": "func (*${typename})","title": "func (...) {...}","value": "func (${1:${typename_abbr}} ${2:*}${typename}) ${3:name}($4)$5 {\n\t$0\n}" },{ "text": "test function","title": "tf","value": "func Test$1(t *testing.T) {\n\t$0\n}" },{ "text": "benchmark function","title": "bf","value": "func Benchmark$1(b *testing.B) {\n\tfor ${2:i} := 0; ${2:i} < b.N; ${2:i}++ {\n\t\t$0\n\t}\n}" },] },{ "match": {"local": true},"snippets": [ {"text": "func","title": "func{...}()","value": "func($1) {\n\t$0\n}($2)"},"title": "var [name] [type]","value": "var ${1:name} ${2:type}"},{ "text": "switch statement","title": "switch","value": "switch ${1:expression} {\ncase ${2:condition}:\n\t$0\n}" },{ "text": "case clause","title": "cs","value": "case ${1:condition}:$0" },{ "text": "for statement","title": "for","value": "for ${1:index} := 0; $1 < ${2:count}; $1${3:++} {\n\t$0\n}" },{ "text": "for range statement","title": "forr","value": "for ${1:var} := range ${2:var} {\n\t$0\n}" },{ "text": "channel declaration","title": "ch","value": "chan ${1:type}" },{ "text": "map declaration","title": "map","value": "map[${1:type}]${2:type}" },{ "text": "empty interface","title": "in","value": "interface{}" },{ "text": "if statement","title": "if","value": "if ${1:condition} {\n\t$0\n}" },{ "text": "else branch","title": "el","value": "else {\n\t$0\n}" },{ "text": "if else statement","title": "ie","value": "if ${1:condition} {\n\t$2\n} else {\n\t$0\n}" },{ "text": "if err != nil","title": "iferr","value": "if err != nil {\n\t${1:return}\n}" },{ "text": "make(...)","title": "make","value": "make(${1:type},${2:0})" },{ "text": "new(...)","title": "new","value": "new(${1:type})" },{ "text": "panic(...)","title": "pn","value": "panic(\"$0\")" },{ "text": "goroutine anonymous function","title": "go","value": "go func($1) {\n\t$2\n}($0)" },{ "text": "goroutine function","title": "gf","value": "go ${1:func}($0)" },{ "text": "defer statement","title": "df","value": "defer ${1:func}($0)" },] } ],原文链接:https://www.f2er.com/go/189057.html