Skip to content

Commit 4ddd7c0

Browse files
committed
docs: update upgrade guide with more details about mapstructure
1 parent 39ab905 commit 4ddd7c0

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

‎UPGRADE.md‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,24 @@ v := viper.NewWithOptions(
8585

8686
### BREAKING: "github.com/mitchellh/mapstructure" depedency replaced
8787

88-
`mapstructure` package import has changed ([#1723](https://github.com/spf13/viper/pull/1723)) and code like take does not compile anymore
88+
The original [mapstructure](https://github.com/mitchellh/mapstructure) has been [archived](https://github.com/mitchellh/mapstructure/issues/349) and was replaced with a [fork](https://github.com/go-viper/mapstructure) maintained by Viper ([#1723](https://github.com/spf13/viper/pull/1723)).
89+
90+
As a result, the package import path needs to be changed in cases where `mapstructure` is directly referenced in your code.
91+
92+
For example, when providing a custom decoder config:
93+
8994
```go
9095
err := viper.Unmarshal(&appConfig, func(config *mapstructure.DecoderConfig) {
9196
config.TagName = "yaml"
9297
})
9398
```
9499

95-
To fix this issue, replace all instances of imports [`"github.com/mitchellh/mapstructure"`](https://github.com/mitchellh/mapstructure) with [`"github.com/go-viper/mapstructure/v2"`](https://github.com/go-viper/mapstructure/).
100+
The change is fairly straightforward, just replace all occurrences of the import path `github.com/mitchellh/mapstructure` with `github.com/go-viper/mapstructure/v2`:
101+
102+
```diff
103+
- import "github.com/mitchellh/mapstructure"
104+
+ import "github.com/go-viper/mapstructure/v2"
105+
```
96106

97107
### BREAKING: HCL, Java properties, INI removed from core
98108

0 commit comments

Comments
 (0)