jmattheis / goverter

Generate type-safe Go converters by simply defining an interface
https://goverter.jmattheis.de/
MIT License
496 stars 46 forks source link

wrap custom convertion #26

Closed kliko9 closed 2 years ago

kliko9 commented 2 years ago

Is your feature request related to a problem? Please describe.


type Input struct {
  V1, V2 float64
}

type Output [2]float64

func Custom(in Input) Output {
  ...
}

type Converter interface {
  Output(Input) Output
}

Describe the solution you'd like The generated code be like:

type Converter struct {}
...
func (c *Converter) Output(source Input) Output {
  return Custom(source)
}

Right now goverter seems to not find this custom and throws error that it could't convert those two values. Describe alternatives you've considered For sure I could use my custom function directly but I would prefer to not mix custom functions with converter's method calls.

jmattheis commented 2 years ago

Fixed with v0.8.1