Wie vergleiche ich 2 Funktionen in Go?

Zum Beispiel habe ich eine Liste von Funktionen, die ich vergleichen möchte:

http: //play.golang.org/p/_rCys6ryn

type Action func(foo string)

type Handler struct {
  Get Action
  Post Action
}

var routes map[string]Handler

func Undefined(foo string) {
}

func Defined(foo string) {
}

func init() {
  routes = map[string]Handler{
    `/`: Handler{Defined,Undefined},
  }
}

func main() {
  for _, handler := range routes {
    if handler.Post != Undefined { 
      // do something
    } // invalid operation: (func(string))(handler.Post) != Undefined (func can only be compared to nil)


    if &handler.Post != &Undefined { 
      // do something 
    } // cannot take the address of Undefined
    // invalid operation: &handler.Post != &Undefined (mismatched types *Action and *func(string))
  }
}

Was ist die richtige Art zu vergleichen, wenn zwei Funktionen gleich sind?

Antworten auf die Frage(6)

Ihre Antwort auf die Frage