You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
514 B

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