In Go, it's possible to create function types (https://golang.org/ref/spec#Function_types) like this
type Printer func(s string)
How can I find all of the functions which satisfy this type? For example, if I had the file below, how could I find out that consolePrinter
is a Printer
?
package main
import "fmt"
func main() {
printToScreen(consolePrinter)
}
// Printer defines a function that prints a string.
type Printer func(s string)
func printToScreen(p Printer) {
p("Hello")
}
// consolePrinter is a Printer (the function signature is identical).
func consolePrinter(s string) {
fmt.Println(s)
}
I tried out guru, but the implements
feature doesn't seem to support function types.
guru implements ./main.go:#134
/Users/adrian/go/gurutest/main.go:10.6-10.12: signature type Printer implements only interface{}