maxbrunsfeld / counterfeiter

A tool for generating self-contained, type-safe test doubles in go
MIT License
931 stars 90 forks source link

Generate doesn't import packages referenced in type args #260

Open Ralph7C2 opened 9 months ago

Ralph7C2 commented 9 months ago

If an interface method or function uses a generic type with a specified type parameter, like:

type SomeInterface interface {
    Do(o Optional[pkg.SomeType])
}

The generated file will use Optional[pkg.SomeType], but not import pkg.

While there is a lot more work to fully support generic interfaces, this would improve interfaces that handle other generic types.

I've created a PR that fixes this: https://github.com/maxbrunsfeld/counterfeiter/pull/258