Re: [go-nuts] Best design to copy a struct

2020-04-21 Thread Kevin Chadwick
On 2020-04-21 10:09, Thomas S wrote: >> But most of the time for getting a copy of a struct, I do something like >> this : >> >> func (re Regexp) Copy() *Regexp { >>    119 return &re >>    120  } If you are just trying to shallow copy a struct then I find this pointer usage distasteful. Far mor

Re: [go-nuts] Best design to copy a struct

2020-04-21 Thread Thomas S
I did not know this stylistic guideline. Thank you Ian ! Le mardi 21 avril 2020 00:42:39 UTC+2, Ian Lance Taylor a écrit : > > On Mon, Apr 20, 2020 at 1:56 PM Thomas S > > wrote: > > > > In regexp package, the "copy" function is implemented like this : > > > > func (re *Regexp) Copy() *Regex

Re: [go-nuts] Best design to copy a struct

2020-04-20 Thread Ian Lance Taylor
On Mon, Apr 20, 2020 at 1:56 PM Thomas S wrote: > > In regexp package, the "copy" function is implemented like this : > > func (re *Regexp) Copy() *Regexp { >118 re2 := *re >119 return &re2 >120 } > > > But most of the time for getting a copy of a struct, I do something like this

[go-nuts] Best design to copy a struct

2020-04-20 Thread Thomas S
Hello, In regexp package, the "copy" function is implemented like this : func (re *Regexp) Copy() *Regexp { 118re2 := *re 119return &re2 120 } But most of the time for getting a copy of a struct, I do something like this : func (re Regexp) Copy() *Regexp { 119