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 committed Sep 6, 2024
1 parent b49c602 commit 3cc9013
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 := 0; i < v.NumFields(); i++ {
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 3cc9013

Please sign in to comment.