8000 Use aliases for declaring context and update arguments · Issue #178 · jmattheis/goverter · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Use aliases for declaring context and update arguments #178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jmattheis opened this issue Jan 12, 2025 · 0 comments
Open

Use aliases for declaring context and update arguments #178

jmattheis opened this issue Jan 12, 2025 · 0 comments
Labels
feature New feature or request

Comments

@jmattheis
Copy link
Owner

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.

@jmattheis jmattheis added the feature New feature or request label Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant
0