Each call to Run could check if the struct has been initialized and 
initialize it if not. An approach is a function field could be swapped out 
after initialization.

Matt

On Thursday, April 26, 2018 at 11:55:07 AM UTC-5, Nimrod Shneor wrote:
>
> Hey everyone,
> I've encountered a design issue - 
> I have an the following interface -
>
> type Runner interface {
>   Run(x X,y Y)
> }
>
> I want to add to it an Init(...) method which will initialize the internal 
> fields of the Runner before performing `Run`..
> My issue is that different structs implementing the `Runner` interface 
> require different fields in order to initialize, How should I solve this?
>
> Thanks a lot!
> Nimrod.
>

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to