I am trying to see if Go supports a language feature I use in other OO languages (such as Java). I'd like to define a few interfaces and pass an object that supports some of them to a function as a parameter.
In Java I might define a bunch of single method interfaces like HasAdd, HadMul, HasSub, HasDiv, HasSin, HasCos, HasTan, etc.
And then I might define a generic method whose argument T is defined as
<T extends HasSin & HasAdd>. I pass in a T to the method. Note I don't have to define an intermediate Interface that contains both HasSin and HasAdd. (Which is great because n interfaces results in needing 2^n intermediate interfaces to cover all cases).
I know go does not support generics. But can it do something like func(HasSin & HasAdd obj)? It seems it should support this behavior. I just haven't found documentation that cinches it either way.
I have seen this: https://golangbot.com/interfaces-part-2/ where there is an example of something similar near the bottom of the article but it does indeed use an intermediate interface.