3 ms·
I think its best to paste some code, i.e, the code (theoretically) meeting your requirements that failed, and code that compiled and got the closest to meeting
by markoman 4y ago
I think its best to paste some code, i.e, the code (theoretically) meeting your requirements that failed, and code that compiled and got the closest to meeting your requirements.
Hopefully someone can bridge that gap for you.
- wara23arish 4y agoI made an example of what Im trying to do. https://goplay.tools/snippet/Vj7uVMi0mWn https://goplay.tools/snippet/Vj7uVMi0mWn Basically have two different types that implement an interface, pass them into a receiver function in a composite type (array,slice). Part of the issue is that you cant have the receiver function without defining instantiating the type on the receiver Spotter in this case.
- markoman 4y agoYou don't actually have to instantiate the type for a receiver function (i.e., method). There's too much missing from your code for me to understand which direction you're going but you'll likely have to use a constraint for structs which is explained here: https://github.com/akutz/go-generics-the-hard-way/blob/main/04-getting-going/04-structural-constraints.md https://github.com/akutz/go-generics-the-hard-way/blob/main/...