How would one print the method set of the following interface?
type Searcher interface { Search(query string) (found bool, err error) ListSearches() []st
Using reflection:
t := reflect.TypeOf(new(Searcher)).Elem() fmt.Println(t) for i := 0; i < t.NumMethod(); i++ { fmt.Println(t.Method(i).Name) }
Prints:
main.Searcher ClearSearches ListSearches Search