Skip to content
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

Allow to set a Prefix for the setter functions #31

Open
carloscasalar opened this issue Nov 16, 2024 · 0 comments
Open

Allow to set a Prefix for the setter functions #31

carloscasalar opened this issue Nov 16, 2024 · 0 comments

Comments

@carloscasalar
Copy link

I think it would be great to be able to set a prefix for the setter functions.

For example:

//go:generate gonstructor --type=Structure --constructorTypes=builder --setterPrefix=With
type Structure struct {
	foo string
}

Could generate:

type StructureBuilder struct {
	foo        string
}

func NewStructureBuilder() *StructureBuilder {
	return &StructureBuilder{}
}

func (b *StructureBuilder) WithFoo(foo string) *StructureBuilder {
	b.foo = foo
	return b
}

func (b *StructureBuilder) Build() *Structure {
	return &Structure{
		foo:        b.foo,
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant