Created
March 4, 2022 12:21
-
-
Save jfjensen/0413e4376371ee7b2fdd92a77c1e6488 to your computer and use it in GitHub Desktop.
This is the template for creating the Concrete targets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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