package builder type Builder interface { Build() } type Director struct { build Builder } func NewDirector(b Builder) Director { return Director{build: b} } func (d *Director) Construct() { d.build.Build() } type ConcreteBuilder struct { Built bool } func NewConcreteBuilder() ConcreteBuilder { return ConcreteBuilder{Built: false} } func (b *ConcreteBuilder) Build() { b.Built = true } type Product struct { Built bool } func (b *ConcreteBuilder) GetResult() Product { return Product{b.Built} }