[feat] 新增配置项

This commit is contained in:
2023-07-24 13:39:12 +08:00
parent 32031a7f53
commit 7f50d9eef1
3 changed files with 59 additions and 9 deletions
+30
View File
@@ -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...)
}}
}