this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

listests: do not panic if not in a module

+12 -8
+1 -1
listests/internal/testmodule/some_test.go
··· 91 91 t.Run("t1", func(t *testing.T) { 92 92 cases := []struct { 93 93 input string 94 - want any 94 + want string 95 95 }{ 96 96 {"tt1", "tt1"}, 97 97 {"tt2 with space", "tt2 with space"},
+11 -7
listests/main.go
··· 249 249 continue 250 250 } 251 251 252 - moduleName := pkg.Module.Path 252 + // TODO: To not get panic when running on for file(s) not in a module. 253 253 pkgPath := pkg.PkgPath 254 - packageName := strings.TrimPrefix(pkgPath, moduleName+"/") 254 + packageName := pkgPath 255 + if pkg.Module != nil { 256 + moduleName := pkg.Module.Path 257 + packageName = strings.TrimPrefix(pkgPath, moduleName+"/") 258 + } 255 259 directory := pkg.Dir 256 260 257 261 inspect := inspector.New(testFiles) ··· 571 575 return positions 572 576 } 573 577 574 - var pos int 575 - for _, field := range structType.Fields.List { 576 - pos++ 577 - 578 + for pos, field := range structType.Fields.List { 578 579 if len(field.Names) == 0 { 579 - // Anonymous. 580 + // Anonymous field. 581 + pos++ 580 582 continue 581 583 } 582 584 585 + // Named fields. 583 586 for _, name := range field.Names { 584 587 positions[name.Name] = pos 588 + pos++ 585 589 } 586 590 } 587 591