27 lines
353 B
Go
27 lines
353 B
Go
![]() |
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(""))
|
||
|
}
|