diff --git a/mockgen/model/model.go b/mockgen/model/model.go index 94d7f4ba..0fa4a2c8 100644 --- a/mockgen/model/model.go +++ b/mockgen/model/model.go @@ -413,9 +413,15 @@ func typeFromType(t reflect.Type) (Type, error) { } if imp := t.PkgPath(); imp != "" { + tp := t.Name() + if l, r := strings.Index(tp, "["), strings.Index(tp, "]"); l != -1 && r != -1 { + content := tp[l+1 : r] + sp := strings.Split(content, "/") + tp = tp[:l+1] + sp[len(sp)-1] + tp[r:] + } return &NamedType{ Package: impPath(imp), - Type: t.Name(), + Type: tp, }, nil }