Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature request] funk.Get map value with non-trivial key #155

Closed
marcinc opened this issue Aug 25, 2022 · 0 comments
Closed

[feature request] funk.Get map value with non-trivial key #155

marcinc opened this issue Aug 25, 2022 · 0 comments

Comments

@marcinc
Copy link
Contributor

marcinc commented Aug 25, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants