fix: typo

This commit is contained in:
yinpeng 2024-04-30 19:10:35 +08:00
parent ea35b92596
commit 591241a57f
4 changed files with 11 additions and 11 deletions

View file

@ -718,9 +718,9 @@ The resulting code is easy to test, since it's decoupled from the main config st
and easier to reuse (for the same reason).
### Unmarshaling
### Unmarshalling
You also have the option of Unmarshaling all or a specific value to a struct, map,
You also have the option of Unmarshalling all or a specific value to a struct, map,
etc.
There are two methods to do this:
@ -771,7 +771,7 @@ var C config
v.Unmarshal(&C)
```
Viper also supports unmarshaling into embedded structs:
Viper also supports unmarshalling into embedded structs:
```go
/*
@ -802,7 +802,7 @@ if err != nil {
}
```
Viper uses [github.com/mitchellh/mapstructure](https://github.com/mitchellh/mapstructure) under the hood for unmarshaling values which uses `mapstructure` tags by default.
Viper uses [github.com/mitchellh/mapstructure](https://github.com/mitchellh/mapstructure) under the hood for unmarshalling values which uses `mapstructure` tags by default.
### Decoding custom formats

View file

@ -1,8 +1,8 @@
# Troubleshooting
## Unmarshaling doesn't work
## Unmarshalling doesn't work
The most common reason for this issue is improper use of struct tags (eg. `yaml` or `json`). Viper uses [github.com/mitchellh/mapstructure](https://github.com/mitchellh/mapstructure) under the hood for unmarshaling values which uses `mapstructure` tags by default. Please refer to the library's documentation for using other struct tags.
The most common reason for this issue is improper use of struct tags (eg. `yaml` or `json`). Viper uses [github.com/mitchellh/mapstructure](https://github.com/mitchellh/mapstructure) under the hood for unmarshalling values which uses `mapstructure` tags by default. Please refer to the library's documentation for using other struct tags.
## Cannot find package

View file

@ -51,7 +51,7 @@ func (rc remoteConfigProvider) WatchChannel(rp viper.RemoteProvider) (<-chan *vi
}
quit := make(chan bool)
quitwc := make(chan bool)
viperResponsCh := make(chan *viper.RemoteResponse)
viperResponseCh := make(chan *viper.RemoteResponse)
cryptoResponseCh := cm.Watch(rp.Path(), quit)
// need this function to convert the Channel response form crypt.Response to viper.Response
go func(cr <-chan *crypt.Response, vr chan<- *viper.RemoteResponse, quitwc <-chan bool, quit chan<- bool) {
@ -67,9 +67,9 @@ func (rc remoteConfigProvider) WatchChannel(rp viper.RemoteProvider) (<-chan *vi
}
}
}
}(cryptoResponseCh, viperResponsCh, quitwc, quit)
}(cryptoResponseCh, viperResponseCh, quitwc, quit)
return viperResponsCh, quitwc
return viperResponseCh, quitwc
}
func getConfigManager(rp viper.RemoteProvider) (crypt.ConfigManager, error) {

View file

@ -432,7 +432,7 @@ func TestDefault(t *testing.T) {
assert.Equal(t, "leather", v.Get("clothing.jacket"))
}
func TestUnmarshaling(t *testing.T) {
func TestUnmarshalling(t *testing.T) {
v := New()
v.SetConfigType("yaml")
r := bytes.NewReader(yamlExample)
@ -2191,7 +2191,7 @@ func TestMergeConfigMap(t *testing.T) {
assertFn(1234)
}
func TestUnmarshalingWithAliases(t *testing.T) {
func TestUnmarshallingWithAliases(t *testing.T) {
v := New()
v.SetDefault("ID", 1)
v.Set("name", "Steve")