I'm trying to retrieving a value from a map within a map. I have followed online tutorials but not getting the right answer. This is my program:
type OptionMap map[string]interface{}
func(options OptionMap) {
opt, _ := options["data2"].(OptionMap)
fmt.Println("opt", opt)
for key, value := range options {
fmt.Println("Key:", key, "Value:", value)
}
}
options has two keys data1 and data2 . Inside for loop the printf prints following
Key: data1 Value: false
Key: data2 Value: map[h:5]
When I run the code
opt, _ := options["data2"].(OptionMap)
I'm getting nil
in opt
. I'm not sure how to retrieve value of map[h:5]
.