Skip to content

Commit

Permalink
feat: use github.com/sandwich-go/mapstructure
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengyang.zhu committed Sep 30, 2024
1 parent 9585f66 commit 07b5f74
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func SaveVarToWriterAsYAML(valPtr interface{}, writer io.Writer) error
- `WithTagNameDefaultValue`: The Tag name used for the default value, default `default`.
- `WithParseDefault`: whether to parse the default value, default true, recommended to use [optiongen](https://github.com/timestee/optiongen) to generate the default configuration data
- `WithDebug`: debug mode, will output detailed log of parsing process
- `WithDecoderConfigOption`: adjust the mapstructure parameter, `xconf` uses [mapstructure](https://github.com/mitchellh/mapstructure) for type conversion
- `WithDecoderConfigOption`: adjust the mapstructure parameter, `xconf` uses [mapstructure](https://github.com/sandwich-go/mapstructure) for type conversion
- `FieldPathDeprecated`: deprecated configuration, no error will be reported when parsing, but a warning log will be printed
- `ErrEnvBindNotExistWithoutDefault`: Error when EnvBind if the specified key does not exist in Env and no default value is specified
- `FieldFlagSetCreateIgnore`: The specified `FieldPath` or type name will not print the warning log when there is no Flag Provider.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func SaveVarToWriterAsYAML(valPtr interface{}, writer io.Writer) error
- `WithTagNameDefaultValue`: 默认值使用的Tag名称 ,默认`default`
- `WithParseDefault`:是否解析默认值,默认true,推荐使用[optiongen](https://github.com/timestee/optiongen)生成默认配置数据
- `WithDebug`: 调试模式,会输出详细的解析流程日志
- `WithDecoderConfigOption`: 调整mapstructure参数,`xconf`使用[mapstructure](https://github.com/mitchellh/mapstructure)进行类型转换
- `WithDecoderConfigOption`: 调整mapstructure参数,`xconf`使用[mapstructure](https://github.com/sandwich-go/mapstructure)进行类型转换
- `FieldPathDeprecated`: 弃用的配置,解析时不会报错,但会打印warning日志
- `ErrEnvBindNotExistWithoutDefault`: EnvBind时如果Env中不存在指定的key而且没有指定默认值时报错
- `FieldFlagSetCreateIgnore`: 指定的`FieldPath`或者类型名在没有Flag Provider的时候,不打印报警日志
Expand Down
6 changes: 3 additions & 3 deletions gen_options_optiongen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ require (
github.com/kr/pretty v0.1.0 // indirect
github.com/mattn/go-runewidth v0.0.13
github.com/mitchellh/hashstructure/v2 v2.0.2
github.com/mitchellh/mapstructure v1.4.3
github.com/sandwich-go/mapstructure v1.6.0
github.com/smartystreets/goconvey v1.7.2
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
)

replace github.com/mitchellh/mapstructure => github.com/sandwich-go/mapstructure v1.4.4-0.20220311064023-afa1d0e26119
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4
github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/sandwich-go/mapstructure v1.4.4-0.20220311064023-afa1d0e26119 h1:CNkHX8WVOJk68EdASU4YRtC4P/hqPCh5WdrHKlFa3KQ=
github.com/sandwich-go/mapstructure v1.4.4-0.20220311064023-afa1d0e26119/go.mod h1:F47FfLZAp8P5fA56KOdW5+Eks8qaa4yfpf49SVSiJ0U=
github.com/sandwich-go/mapstructure v1.6.0 h1:FwXGUFVBAkN8CUws4jmV4+Nmg7fEKq/KeQTPZl5agSc=
github.com/sandwich-go/mapstructure v1.6.0/go.mod h1:F47FfLZAp8P5fA56KOdW5+Eks8qaa4yfpf49SVSiJ0U=
github.com/smartystreets/assertions v1.2.0 h1:42S6lae5dvLc7BrLu/0ugRtcFVjoJNMC/N3yZFZkDFs=
github.com/smartystreets/assertions v1.2.0/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo=
github.com/smartystreets/goconvey v1.7.2 h1:9RBaZCeXEQ3UselpuwUQHltGVXvdwm6cv1hgR6gDIPg=
Expand Down
2 changes: 1 addition & 1 deletion mapstructure.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package xconf
import (
"reflect"

"github.com/mitchellh/mapstructure"
"github.com/sandwich-go/mapstructure"
)

// DecoderConfigOption A DecoderConfigOption can be passed to Unmarshal to configure mapstructure.DecoderConfig options
Expand Down
3 changes: 2 additions & 1 deletion option.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ xconf-providers: https://github.com/sandwich-go/xconf-providers
var powerBy = `Powered by: https://github.com/sandwich-go/xconf`

// OptionsOptionDeclareWithDefault go-lint
//
//go:generate optiongen --option_with_struct_name=false --xconf=true --usage_tag_name=usage
func OptionsOptionDeclareWithDefault() interface{} {
return map[string]interface{}{
Expand All @@ -54,7 +55,7 @@ func OptionsOptionDeclareWithDefault() interface{} {
"ErrorHandling": (ErrorHandling)(PanicOnError),
// annotation@TagName(comment="xconf使用的字段TAG名称,默认:xconf")
"TagName": string(DefaultTagName),
// annotation@DecoderConfigOption(comment="xconf内部依赖mapstructure,改方法用户用户层自定义mapstructure解析参数,参考:https://github.com/mitchellh/mapstructure")
// annotation@DecoderConfigOption(comment="xconf内部依赖mapstructure,改方法用户用户层自定义mapstructure解析参数,参考:https://github.com/sandwich-go/mapstructure")
"DecoderConfigOption": []DecoderConfigOption(nil),
// annotation@MapMerge(comment="map是否开启merge模式,详情见文档")
"MapMerge": false,
Expand Down
2 changes: 1 addition & 1 deletion xconf.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"reflect"

"github.com/mitchellh/hashstructure/v2"
"github.com/mitchellh/mapstructure"
"github.com/sandwich-go/mapstructure"
"github.com/sandwich-go/xconf/xflag"
"github.com/sandwich-go/xconf/xutil"
)
Expand Down

0 comments on commit 07b5f74

Please sign in to comment.