{ "iferr": { "prefix": "iferr", "description": "Expansion `if err != nil ...`", "body": [ "if err != nil {", "\t$1", "}" ] }, "multiple imports": { "prefix": "ims", "body": "import (\n\t\"${1:package}\"\n)", "description": "Snippet for a import block" }, "multiple constants": { "prefix": "cos", "body": "const (\n\t${1:name} = ${2:value}\n)", "description": "Snippet for a constant block" }, "variables declaration": { "prefix": "vars", "body": "var (\n\t${1:name} ${2:type} = ${3:value}\n)", "description": "Snippet for a variable" }, "error return": { "prefix": "rerr", "description": "if err != nil { return err }", "body": [ "if err != nil {", "\treturn err", "}" ] }, "error panic": { "prefix": "perr", "description": "if err != nil { return panic(err) }", "body": [ "if err != nil {", "\tpanic(err)", "}" ] }, "tdd func": { "prefix": "ftdd", "description": "table driven test", "body": [ "func Test$1(t *testing.T) {", "\tt.Parallel()", "", "\tpatterns := []struct {", "\t\tname string", "\t}{", "\t\t{", "\t\t\tname: \"success\",", "\t\t},", "\t}", "", "\tfor _, tt := range patterns {", "\t\ttt := tt", "\t\tt.Run(tt.name, func(t *testing.T) {", "\t\t\tt.Parallel()", "", "\t\t\t$3", "\t\t})", "\t}", "}" ] }, "empty func": { "prefix": "func", "description": "empty func", "body": [ "func $1() {", "\t$2", "}" ] }, "goroutine anonymous function": { "prefix": "go", "body": "go func($1) {\n\t$0\n}($2)", "description": "Snippet for anonymous goroutine declaration" }, "graceful shutdown": { "prefix": "shutdown", "description": "graceful shutdown", "body": [ "ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGTERM, syscall.SIGINT)", "defer cancel()", "<-ctx.Done()", "log.Info(\"root context canceled, shutdown\")" ] }, "check interface": { "prefix": "ifcheck", "description": "inteface check", "body": [ "var _ ${1:interface} = (*${2:struct})(nil)" ] }, "type function declaration": { "prefix": "tyf", "body": "type ${1:name} func($3) $4", "description": "Snippet for a type function declaration" }, "type interface declaration": { "prefix": "tyi", "body": "type ${1:name} interface {\n\t$0\n}", "description": "Snippet for a type interface" }, "type struct declaration": { "prefix": "tys", "body": "type ${1:name} struct {\n\t$0\n}", "description": "Snippet for a struct declaration" }, "switch statement": { "prefix": "switch", "body": "switch ${1:expression} {\ncase ${2:condition}:\n\t$0\n}", "description": "Snippet for switch statement" }, "make(...)": { "prefix": "make", "body": "make(${1:type}, ${2:0})", "description": "Snippet for make statement" }, "new(...)": { "prefix": "new", "body": "new(${1:type})", "description": "Snippet for new statement" } }