建造者模式

package models

type Book struct {
	Id       int    // required
	BookName string // required
	Price    float64
}

func (this *Book) Builder(id int, name string) *BookBuilder {
	return NewBookBuilder(id, name)
}

func (this *Book) GetInfo() string {
	return "book"
}

type Briefs struct {
	Id   int
	Size string
}

func (this *Briefs) GetInfo() string {
	return "内裤"
}

最后更新于