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) { ... }) } }