On Wednesday, May 4, 2022 at 7:01:48 AM UTC+8 se...@liao.dev wrote:

> right now it only works if the structs are actually identical:
> https://go.dev/play/p/tMG3SYG5fLN
>
> - sean
>
>
Though accessing fields is still not allowed.
 

>
> On Tue, May 3, 2022 at 8:06 PM sbezverk <sbez...@gmail.com> wrote:
>
>> Hello,
>>
>>  
>>
>> 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.
>>
>>  
>>
>> Thank you and appreciate a lot your help.
>>
>>  
>>
>> Serguei
>>
>> -- 
>> 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...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/D41C14EF-35D1-434F-A719-1E8C88D90C0F%40gmail.com
>>  
>> <https://groups.google.com/d/msgid/golang-nuts/D41C14EF-35D1-434F-A719-1E8C88D90C0F%40gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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/4a99ffe9-8a38-45b7-ae6d-9c12ef6cf058n%40googlegroups.com.

Reply via email to