[feature request] funk.Get map value with non-trivial key
marcinc opened this issue · comments
Marcin Ciszak commented
Currently funk.Get
allows to address map key provided it's a simple name i.e. the key without dots (and other non-word characters).
I'd like to propose that the support for more complex keys is added to the library. This is quite common use occurrence in annotation maps etc. Effectively ability to specify the key as quoted string e.g. some.path."my.special.key"
.
m := map[string]interface{}{
"basic": map[string]interface{}{
"hello": "world",
},
"complex": map[string]interface{}{
"example.com/foo": "bar",
},
}
fmt.Println(funk.Get(m, "basic.hello")) // returns "world" <- this currently works as expected
fmt.Println(funk.Get(m, `complex."example.com/foo"`)) // expected to return "bar"
Am happy to submit PR for it as well.