I have been able to make a function map for methods without a receiver argument. Here is an example.
var funcMap = map[string]func() bool {
"&" : And,
}
func And() bool {
return true && false
}
But if my function has a receiver argument how could I add it to a function map? The below code does not work but tries to show what I want to do.
type Operand struct {
Operator string
Arg1 interface{}
Arg2 interface{}
}
var funcMap = map[string]Operand.func() bool {
"&" : Operand.And,
}
func (o *Operand) And() bool {
return argToBool(o.Arg1) && argToBool(o.Arg2)
}