I've sometimes used them in places where I want to treat
several methods of an object in a uniform way.
For example:
var entryPoints = map[string] func(*MyType, string) error {
"foo": (*MyType).Foo,
"bar": (*MyType).Bar,
}
Another place I've used them is when I need to mock
a method. I'll do:
var myTypeFoo = (*MyType).Foo
and then call myTypeFoo(x) instead of x.Foo. In test code,
I can swap myTypeFoo for a function defined in the test
and interpose custom behaviour.
>>> email to
golang-nuts...@googlegroups.com.
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
golang-nuts...@googlegroups.com.