mapstructure
mapstructure copied to clipboard
Decode underscore value
Hi I have Jason field k8s_version which contain underscore. However I have noticed that I am not able to decode values with _. Just wondering if its a bug or required me to add anything
You can decode those if you tag them like this.
// UserAccount - this type is purposely showing the emailskip field in the data is not present
type User struct {
Name string
IsActive bool `mapstructure:"is_active"`
}
and the data with the _
uinput := map[string]interface{}{
"name": "UserB",
"is_active": true,
}
I found that looking through the notes in the actual source file and in the comments it speaks on how to do it.
Printed Output
main.User{Name:"UserB", IsActive:true}
nonono this is bug

so ga very good
