Skip to content

Instantly share code, notes, and snippets.

@nullren
Created May 29, 2020 16:00
Show Gist options
  • Save nullren/2dc79c167195a964118919e28ba679bf to your computer and use it in GitHub Desktop.
Save nullren/2dc79c167195a964118919e28ba679bf to your computer and use it in GitHub Desktop.

Revisions

  1. Renning Bruns revised this gist May 29, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion example_test.go
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@ func TestTheTestcases(t *testing.T) {
    testcases := []*testcase{...}

    for _, test := range testcases {
    // this is needed to keep `test` in scope. are there alternatives to this pattern?
    // this is needed to keep `test` in scope. are there alternatives to this pattern?
    test := test
    t.Run(test.name, func(t *testing.T) {
    ...
  2. Renning Bruns created this gist May 29, 2020.
    18 changes: 18 additions & 0 deletions example_test.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    package example

    type testcase struct {
    name string
    ...
    }

    func TestTheTestcases(t *testing.T) {
    testcases := []*testcase{...}

    for _, test := range testcases {
    // this is needed to keep `test` in scope. are there alternatives to this pattern?
    test := test
    t.Run(test.name, func(t *testing.T) {
    ...
    })
    }
    }