[feat] 新增配置项
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package engine
|
||||
|
||||
type engineOptions struct {
|
||||
debug bool
|
||||
relations []string
|
||||
}
|
||||
|
||||
type EngineOption interface {
|
||||
apply(*engineOptions)
|
||||
}
|
||||
|
||||
type fnOption struct {
|
||||
f func(*engineOptions)
|
||||
}
|
||||
|
||||
func (this fnOption) apply(do *engineOptions) {
|
||||
this.f(do)
|
||||
}
|
||||
|
||||
func Debug() EngineOption {
|
||||
return &fnOption{f: func(o *engineOptions) {
|
||||
o.debug = true
|
||||
}}
|
||||
}
|
||||
|
||||
func Relation(opts ...string) EngineOption {
|
||||
return &fnOption{f: func(o *engineOptions) {
|
||||
o.relations = append(o.relations, opts...)
|
||||
}}
|
||||
}
|
||||
Reference in New Issue
Block a user