Passing a collection of interface types to a function
问题 I'm having trouble figuring out the correct way to use interfaces in Go. My function needs to take a map of items that implement a certain method. It looks like this: type foo interface { bar() string } func doSomething(items map[string]foo) { } I'm trying to call this function with a type that implements the foo interface. type baz struct { } func (b baz) bar() string { return "hello" } items := map[string]baz{"a": baz{}} doSomething(items) But I get the following error: cannot use items