Skip to content

Support for getters & setters (for gRPC Opaque API) #179

Open
@applejag

Description

@applejag

Is your feature request related to a problem? Please describe.
Support for this:

type Foo struct {
	name string
}

func (f *Foo) GetName() string { return f.name }

func (f *Foo) SetName(name string) { f.name = name }


type Bar struct {
	Name string
}


type Converter interface {
	ConvertFoo(foo Foo) Bar
	ConvertBar(bar Bar) Foo
}

This is the general idea of how Go's new gRPC Opaque API works: https://go.dev/blog/protobuf-opaque

But when trying this I get this:

func (c *ConverterImpl) ConvertFoo(source models.Foo) models.Bar {
	var modelsFoo models.Foo
	_ = source
	return modelsFoo
}

Describe the solution you'd like
goverter should try look for Get{{ .Name }} and Set{{ .Name }} if no field is found.

Describe alternatives you've considered
nothing comes to mind

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