Skip to content

Instantly share code, notes, and snippets.

@abtris
Last active December 7, 2020 07:08
Show Gist options
  • Select an option

  • Save abtris/e6ba014d1e74afe58fc093bd7a3e87cd to your computer and use it in GitHub Desktop.

Select an option

Save abtris/e6ba014d1e74afe58fc093bd7a3e87cd to your computer and use it in GitHub Desktop.

Revisions

  1. abtris revised this gist Dec 7, 2020. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion go.json
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,13 @@
    "go simple test": {
    "prefix": "test",
    "body": [
    "func Test${1:Name}(t *testing.T) {\n\t$0\n}"
    "func Test${1:Name}(t *testing.T) {\t",
    "\texpected := 0",
    "\treal :=$0",
    "\tif real != expected {",
    "\t\tt.Errorf(\"Expected %v and real %v)\", expected, real)",
    "\t}",
    "}"
    ],
    "description": "Simple test skeleton"
    },
  2. abtris created this gist Dec 4, 2020.
    50 changes: 50 additions & 0 deletions go.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,50 @@
    {
    "go main function": {
    "prefix": "main",
    "body": [
    "package main",
    "",
    "func main() {\n\t$0\n}"
    ],
    "description": "Main func"
    },
    "go simple test": {
    "prefix": "test",
    "body": [
    "func Test${1:Name}(t *testing.T) {\n\t$0\n}"
    ],
    "description": "Simple test skeleton"
    },
    "go simple bench": {
    "prefix": "bench",
    "body": [
    "func Benchmark${1:Name}(b *testing.B) {\n\tfor n := 0; n < b.N; n++ {\n\t\t$0\n\t}\n}"
    ],
    "description": "Simple benchmark skeleton"
    },
    "go table test": {
    "prefix": "ttest",
    "body": [
    "func Test${1:Name}(t *testing.T) {",
    "\ttests := []struct {",
    "\t\tname string",
    "\t\tx string",
    "\t\ty []string",
    "\t\tresult bool",
    "}{",
    "\t\t{name: \"simple\", x:\"test\", y: []string{\"test\", \"nil\"}, result: true}",
    "\t}",
    "\tfor _, test := range tests {",
    "\t\tt.Run(test.name, func(t *testing.T) {",
    "\t\t\tresult, _ := ExampleFunc(test.x, test.y)",
    "\t\t\tif result != test.result {",
    "\t\t\t\tt.Errorf(\"Expected %v and real %v)\", test.result, result)",
    "\t\t\t}",
    "\t\t})",
    "\t}",
    "}"
    ],
    "description": "Table test skeleton"
    },

    }