Skip to content

Instantly share code, notes, and snippets.

@jfjensen
Created March 4, 2022 12:21
Show Gist options
  • Save jfjensen/0413e4376371ee7b2fdd92a77c1e6488 to your computer and use it in GitHub Desktop.
Save jfjensen/0413e4376371ee7b2fdd92a77c1e6488 to your computer and use it in GitHub Desktop.
This is the template for creating the Concrete targets
package main
{{$target := index .ConcreteTargets 0}}
type {{$target}}Builder struct {
{{range .Properties -}}
{{.Name}} {{.TypeName}}
{{end -}}
}
func new{{title $target}}Builder() *{{$target}}Builder {
return &{{$target}}Builder{}
}
{{range .Properties}}
func (b *{{$target}}Builder) set{{if eq .TypeName `int`}}Num{{end}}{{title .Name}}() {
b.{{.Name}} = *new({{.TypeName}}) // replace this!!
}
{{end}}
func (b *{{$target}}Builder) get{{title .ProductTarget}}() {{.ProductTarget}} {
return {{.ProductTarget}}{
{{range .Properties -}}
{{.Name}}: b.{{.Name}},
{{end -}}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment