thoas / go-funk

A modern Go utility library which provides helpers (map, find, contains, filter, ...)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Does Find() work on a map?

jeffsaremi opened this issue · comments

I can't get this to work:

	mymap := map[string]string {
	"one": "1",
	"two": "2",
	}
  key, value := funk.Find(mymap, func(k,v string) bool {
    return v == "2"
 }

@jeffsaremi funk find supports funcition has one input parameter and one output response. The type of input is the type of element in the array or map. The type of output is bool.
Code fix

 mymap := map[string]string{
    "one": "1",
    "two": "2",
 }
 value := Find(mymap, func(v string) bool {
    return v == "2"
 })
 fmt.Println(value) // "2"