Skip to content

Commit

Permalink
feat: support types.Struct as interface args
Browse files Browse the repository at this point in the history
  • Loading branch information
tomMoulard authored Feb 7, 2025
1 parent 77e6780 commit d5507e7
Show file tree
Hide file tree
Showing 5 changed files with 640 additions and 0 deletions.
7 changes: 7 additions & 0 deletions mocktail.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,13 @@ func getTypeImports(t types.Type) []string {
case *types.Array:
return getTypeImports(v.Elem())

case *types.Struct:
var imports []string
for i := range v.NumFields() {
imports = append(imports, getTypeImports(v.Field(i).Type())...)
}
return imports

case *types.Map:
imports := getTypeImports(v.Key())
imports = append(imports, getTypeImports(v.Elem())...)
Expand Down
1 change: 1 addition & 0 deletions testdata/src/a/a.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type Coconut interface {
Zoo(st interface{}) string
Moo(fn func(st, stban Strawberry) Pineapple) string
Noo(ar [][2]string) string
Poo(str struct{ name string }) string
}

type Water struct{}
Expand Down
Loading

0 comments on commit d5507e7

Please sign in to comment.