37 lines
714 B
Go
37 lines
714 B
Go
package codec
|
|
|
|
import (
|
|
"go_dreamfactory/lego/sys/codec/core"
|
|
"go_dreamfactory/lego/sys/log"
|
|
"go_dreamfactory/lego/utils/mapstructure"
|
|
)
|
|
|
|
func newOptions(config map[string]interface{}, opts ...core.Option) core.Options {
|
|
options := core.Options{
|
|
IndentionStep: 2,
|
|
}
|
|
if config != nil {
|
|
mapstructure.Decode(config, &options)
|
|
}
|
|
for _, o := range opts {
|
|
o(&options)
|
|
}
|
|
if options.Debug && options.Log == nil {
|
|
options.Log = log.Clone()
|
|
}
|
|
return options
|
|
}
|
|
|
|
func newOptionsByOption(opts ...core.Option) core.Options {
|
|
options := core.Options{
|
|
IndentionStep: 2,
|
|
}
|
|
for _, o := range opts {
|
|
o(&options)
|
|
}
|
|
if options.Debug && options.Log == nil {
|
|
options.Log = log.Clone()
|
|
}
|
|
return options
|
|
}
|