package common type Model struct { TableName string } type Option func(model *Model) func withModel(tableName string) Option { return func(model *Model) { model.TableName = tableName } } func NewModel(option ...Option) *Model { out := new(Model) for _, v := range option { v(out) } return out } func Test() { NewModel(withModel("")) }