go_dreamfactory/sys/configure/options.go
2022-06-21 15:41:55 +08:00

35 lines
667 B
Go

package configure
import (
"go_dreamfactory/lego/utils/mapstructure"
)
type Option func(*Options)
type Options struct {
ConfigurePath string //配置中心路径
CheckInterval int //配置文件更新检查间隔时间 单位秒
}
func newOptions(config map[string]interface{}, opts ...Option) (Options, error) {
options := Options{
CheckInterval: 60,
}
if config != nil {
mapstructure.Decode(config, &options)
}
for _, o := range opts {
o(&options)
}
return options, nil
}
func newOptionsByOption(opts ...Option) (Options, error) {
options := Options{
CheckInterval: 60,
}
for _, o := range opts {
o(&options)
}
return options, nil
}