jmattheis / goverter

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

Support variables/constants in goverter:map (map custom) #123

Open jmattheis opened 6 months ago

jmattheis commented 6 months ago

Currently only methods are allowed in goverter:map. It would be useful to support variables / constants to, because they are sometimes already present. E.g.

package example

import "time"

// goverter:converter
type Converter interface {
    // goverter:map Value | time:Second
    Convert(Input) Output
}

type Input struct {
    Name string
}
type Output struct {
    Name  string
    Value time.Duration
}

this should normally convert Input#Name -> Output#Name and use the constant time.Second for Output#Value.

Please :+1: this issue if you like this functionality. If you have a specific use-case in mind, feel free to comment it.