On Tue, May 3, 2022 at 12:06 PM sbezverk <sbezv...@gmail.com> wrote:
>

>
> I am starting to learn generics and I was wondering if the following code 
> could be refactored to use genercis, in order to avoid using per type Make() 
> method.
>
>
>
> https://go.dev/play/p/gE4Z6Zj19Is
>
>
>
> I have 3 identical structs, they are defined with different types and used in 
> other types by their unique types. The function to create all 3 types can be 
> consolidated as the actual structure of is the same.
>
>
>
> I am curious it would be possible to leverage generics for this. I have made 
> an attempt but I still need to use per type Make method.

There is no simple way to do this at present.  This is related to
https://go.dev/issue/48522 and https://go.dev/issue/51259.

Ian

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcW-Wxdp_MyvjgqHfMLcGP_-XUwE-B6wenS3V5NuaY97hg%40mail.gmail.com.

Reply via email to