rjeczalik / interfaces

Code generation tools for Go.
MIT License
420 stars 31 forks source link

When method's response are other package struct slice, generated invalid interface. #13

Closed Konboi closed 4 years ago

Konboi commented 4 years ago

I use interfacer and it's very useful but I happen this case.

I define struct like this

package foo

import (
   "github.com/example/hoge"
)

type Foo struct {}

func (f *Foo) Hoge1() error { return nil }

func (f *Foo) Hoge2() *hoge.Hoge { return &hoge.Hoge{} }

func (f *Foo) Hoge3() []*hoge.Hoge { return []*hoge.Hoge{...} }

I generate interface using by interfaces like this.

interfacer -for github.com/Konboi/foo.Foo  -as foo.Fooer -o foo.gen.go

but generated file is like this

package foo

import (
   "github.com/example/hoge"
)

type Fooer interface {
    Hoge1() error
    Hoge2() *hoge.Hoge
    Hoge3() []*github.com/example/hoge.Hoge
}

but I think it should be

package foo

import (
   "github.com/example/hoge"
)

type Fooer interface {
    Hoge1() error
    Hoge2() *hoge.Hoge
    Hoge3() []*hoge.Hoge
}

is it correct ??

please check it.

Konboi commented 4 years ago

fixed :tada: