Skip to content

Use aliases for declaring context and update arguments #178

Description

@jmattheis

Goverter could use the addition of generic type aliases (go1.24), to declare arguments as context or update argument. E.g. the following converter

// goverter:converter
type Converter interface {
    // goverter:update target
    ConvertUpdate(source Input, target *Output) error
    // goverter:context dateFormat
    ConvertContext(source map[string]Input, dateFormat string) map[string]Output
}

could be written as

import "github.com/goverter/arg"

// goverter:converter
type Converter interface {
    ConvertUpdate(source Input, target arg.Target[*Output]) error
    ConvertContext(source map[string]Input, dateFormat arg.Context[string]) map[string]Output
}

where github.com/goverter/arg would contain something like:

type Context[T any] = T
type Target[T any] = T

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions