cheekybits / genny

Elegant generics for Go
MIT License
1.71k stars 167 forks source link

Collect generics into composed interface #61

Open shaunc opened 4 years ago

shaunc commented 4 years ago

I would like

//go:generate genny -in=$GOFILE -out=$GOFILE_gen gen "Datatype=string,int"

type Datatype generic.Type
type GetterDatatype interface {
  GetDataType(column string) (DataType, err)
}
type HasGetters interface {
  GetterDatatype
} 

To expand into

type GetterInt interface {
  GetInt(column string) (int, err)
}
type GetterString interface {
  GetString(column string) (string, err)
}
type HasGetters interface {
  GetterInt
  GetterString
}

But, of course, it doesn't. Is this a worthy enhancement? Is there a workaround to define HasGetters (other than knowing ahead of time what the datatypes are)?

ghostsquad commented 4 years ago

What does it do right now?

gemyago commented 3 years ago

just duplicate entire file basically. Such a feature would be quite useful for me as well.