I have this:
type HandlerCreator = func() struct{}
I am trying to declare a type, where the type is a func that returns a struct{} value.
so, yeah, a HandlerCreator might look like:
type Handler struct{}
func CreateHandler() Handler {
return Handler{}
}
and I am trying to use that type in a map:
var Handlers = map[string]HandlerCreator{
"Register": register.CreateHandler, // <<<< compile error
}
but it says:
cannot use register.CreateHandler (type func() register.Handler) as type func() struct {} in map value
anyone know how to do this?
Golang won't even let me do this:
var Handlers = map[string]func(){
"Register": register.CreateHandler,
}
I get this error:
cannot use register.CreateHandler (type func() register.Handler) as type func() in map value
again, CreateHandler is just a simple func, shown above.