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 <soli...@gmail.com <javascript:>> > 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/ae3f783e-7540-4366-94a4-965040b10dc6%40googlegroups.com.