2022-05-14 17:55:19 +00:00
|
|
|
{
|
|
|
|
// https://snippet-generator.app/
|
|
|
|
"Test case": {
|
2022-09-13 15:58:59 +00:00
|
|
|
"scope": "go",
|
2022-05-14 17:55:19 +00:00
|
|
|
"prefix": "te",
|
|
|
|
"body": [
|
|
|
|
"func Test$1(t *testing.T) {",
|
|
|
|
" $2",
|
|
|
|
"}"
|
|
|
|
],
|
|
|
|
"description": "Test case"
|
|
|
|
},
|
|
|
|
"Assert len": {
|
2022-09-13 15:58:59 +00:00
|
|
|
"scope": "go",
|
2022-05-14 17:55:19 +00:00
|
|
|
"prefix": "al",
|
|
|
|
"body": [
|
|
|
|
"assert.Len(t, $1, $2)"
|
|
|
|
],
|
|
|
|
"description": "Assert len"
|
|
|
|
},
|
|
|
|
"Method with single error result": {
|
2022-09-13 15:58:59 +00:00
|
|
|
"scope": "go",
|
2022-05-14 17:55:19 +00:00
|
|
|
"prefix": "me",
|
|
|
|
"body": [
|
2022-09-05 18:25:54 +00:00
|
|
|
"func (a $1) $2() error {",
|
|
|
|
" return nil",
|
|
|
|
"}"
|
2022-05-14 17:55:19 +00:00
|
|
|
],
|
|
|
|
"description": "Method with single error result"
|
2022-09-05 18:25:54 +00:00
|
|
|
},
|
2022-05-14 17:55:19 +00:00
|
|
|
"if err != nil return err": {
|
2022-09-13 15:58:59 +00:00
|
|
|
"scope": "go",
|
2022-05-14 17:55:19 +00:00
|
|
|
"prefix": "ife",
|
|
|
|
"body": [
|
|
|
|
"if err != nil {",
|
|
|
|
" return err",
|
|
|
|
"}"
|
|
|
|
],
|
|
|
|
"description": "if err != nil return err"
|
|
|
|
},
|
|
|
|
"if _ == nil return fmt.Errorf()": {
|
2022-09-13 15:58:59 +00:00
|
|
|
"scope": "go",
|
2022-05-14 17:55:19 +00:00
|
|
|
"prefix": "ifne",
|
|
|
|
"body": [
|
|
|
|
"if $1 == nil {",
|
|
|
|
" return fmt.Errorf(\"$2 is not defined\")",
|
|
|
|
"}"
|
|
|
|
],
|
|
|
|
"description": "if _ == nil return fmt.Errorf()"
|
|
|
|
},
|
|
|
|
"if err != nil return ``, err": {
|
2022-09-13 15:58:59 +00:00
|
|
|
"scope": "go",
|
2022-05-14 17:55:19 +00:00
|
|
|
"prefix": "iferrs",
|
|
|
|
"body": [
|
|
|
|
"if err != nil {",
|
|
|
|
" return \"\", err",
|
|
|
|
"}"
|
|
|
|
],
|
|
|
|
"description": "if err != nil return ``, err"
|
|
|
|
},
|
|
|
|
"assert.EqualError": {
|
2022-09-13 15:58:59 +00:00
|
|
|
"scope": "go",
|
2022-05-14 17:55:19 +00:00
|
|
|
"prefix": "aee",
|
|
|
|
"body": [
|
2022-09-05 18:25:54 +00:00
|
|
|
"assert.EqualError(t, err, \"..\")"
|
2022-05-14 17:55:19 +00:00
|
|
|
],
|
|
|
|
"description": "assert.EqualError"
|
|
|
|
},
|
|
|
|
"assert.Equal": {
|
2022-09-13 15:58:59 +00:00
|
|
|
"scope": "go",
|
2022-05-14 17:55:19 +00:00
|
|
|
"prefix": "ae",
|
|
|
|
"body": [
|
2022-09-05 18:25:54 +00:00
|
|
|
"assert.Equal(t, \"..\", $1)"
|
2022-05-14 17:55:19 +00:00
|
|
|
],
|
|
|
|
"description": "assert.Equal"
|
|
|
|
},
|
|
|
|
"assert.NoError": {
|
2022-09-13 15:58:59 +00:00
|
|
|
"scope": "go",
|
2022-05-14 17:55:19 +00:00
|
|
|
"prefix": "anoe",
|
|
|
|
"body": [
|
2022-09-05 18:25:54 +00:00
|
|
|
"assert.NoError(t, err)"
|
2022-05-14 17:55:19 +00:00
|
|
|
],
|
|
|
|
"description": "assert.NoError"
|
|
|
|
},
|
|
|
|
"err :=": {
|
2022-09-13 15:58:59 +00:00
|
|
|
"scope": "go",
|
2022-05-14 17:55:19 +00:00
|
|
|
"prefix": "e",
|
|
|
|
"body": [
|
2022-09-05 18:25:54 +00:00
|
|
|
"err := "
|
2022-05-14 17:55:19 +00:00
|
|
|
],
|
|
|
|
"description": "err :="
|
2022-09-05 18:25:54 +00:00
|
|
|
},
|
|
|
|
"Golang Error Wrapper": {
|
2022-09-13 15:58:59 +00:00
|
|
|
"scope": "go",
|
2022-09-05 18:25:54 +00:00
|
|
|
"prefix": "ifew",
|
|
|
|
"body": [
|
|
|
|
"if err != nil {",
|
|
|
|
" return fmt.Errorf(\"$1: %w\", err)",
|
|
|
|
"}$2"
|
|
|
|
],
|
|
|
|
"description": "Golang Error Wrapper"
|
|
|
|
}
|
|
|
|
}
|