On Mon, Apr 20, 2020 at 1:56 PM Thomas S <soligna...@gmail.com> 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 
> :
>
> func (re Regexp) Copy() *Regexp {
>    119 return &re
>    120  }
>
> What do you think ?
> Do I nitpick?

For stylistic reasons, and to avoid confusion, it's often best for all
methods for a specific type to be either all pointer methods or all
value methods.  There are exceptions, but they are rare.  For the type
regexp.Regexp, all methods are pointer methods.

Other than that, I agree that your suggestion would work.

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/CAOyqgcVnbpVqPDCe3H-2kwjE4Ed8GHTuW6VrhUvq2gcen%2BTxuA%40mail.gmail.com.

Reply via email to