To support listeners, is it better is use an interface or a function reference?
I’m new to Go and I come from a Java background. Java objects often have addXXListener methods that provide callback hooks. Those hooks are interface implementations, ideally of an interface containing a single function. That’s the only choice in Java. But in C, the traditional way is using function pointers.
Go provides interfaces and function references. Both of those could be used for callback hooks. An interface has the limitation that it must be backed by an object (a struct instance). A function reference could refer to struct-backed function or a normal function. A function reference seems more flexible. Depending on how you are coding, you might not be developing in a very object-oriented way.
In any case, is there a standard way used in the API for listeners? Do people really code without objects?