Skip to content

Commit d5507e7

Browse files
authored
feat: support types.Struct as interface args
1 parent 77e6780 commit d5507e7

File tree

5 files changed

+640
-0
lines changed

5 files changed

+640
-0
lines changed

mocktail.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,13 @@ func getTypeImports(t types.Type) []string {
216216
case *types.Array:
217217
return getTypeImports(v.Elem())
218218

219+
case *types.Struct:
220+
var imports []string
221+
for i := range v.NumFields() {
222+
imports = append(imports, getTypeImports(v.Field(i).Type())...)
223+
}
224+
return imports
225+
219226
case *types.Map:
220227
imports := getTypeImports(v.Key())
221228
imports = append(imports, getTypeImports(v.Elem())...)

testdata/src/a/a.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type Coconut interface {
3131
Zoo(st interface{}) string
3232
Moo(fn func(st, stban Strawberry) Pineapple) string
3333
Noo(ar [][2]string) string
34+
Poo(str struct{ name string }) string
3435
}
3536

3637
type Water struct{}

0 commit comments

Comments
 (0)