Re: [go-nuts] Refactor to use generics to have a single Make

2022-05-03 Thread tapi...@gmail.com
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 wrote: > >> Hello,

Re: [go-nuts] Refactor to use generics to have a single Make

2022-05-03 Thread 'Sean Liao' via golang-nuts
right now it only works if the structs are actually identical: https://go.dev/play/p/tMG3SYG5fLN - sean On Tue, May 3, 2022 at 8:06 PM sbezverk 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 a

Re: [go-nuts] Refactor to use generics to have a single Make

2022-05-03 Thread Ian Lance Taylor
On Tue, May 3, 2022 at 12:06 PM sbezverk 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,

[go-nuts] Refactor to use generics to have a single Make

2022-05-03 Thread sbezverk
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 t