Skip to content

Commit 26b5fb0

Browse files
authored
feat: improve error when type is not interface
1 parent 8ad1309 commit 26b5fb0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

mocktail.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,10 @@ func walk(root, moduleName string) (map[string]PackageDesc, error) {
148148

149149
interfaceDesc := InterfaceDesc{Name: interfaceName}
150150

151-
interfaceType := lookup.Type().Underlying().(*types.Interface)
151+
interfaceType, ok := lookup.Type().Underlying().(*types.Interface)
152+
if !ok {
153+
return fmt.Errorf("type %q in %q is not an interface", lookup.Type(), fp)
154+
}
152155

153156
for i := 0; i < interfaceType.NumMethods(); i++ {
154157
method := interfaceType.Method(i)

0 commit comments

Comments
 (0)