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 more readable would be
structname2 := structname
or (I wouldn't do this)
func copyStructName(data structname) structname {
return data
}
Caveat: I'm fairly new to go (< 2 years) and dislike a lot of idiomatic code.
e.g. Some Go books say, for clarity I have written this like this but you will
often see it written like this.
Personally I will use the clearer one, not the shorter one, every time??
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/7dc8db1b-fcaa-683c-0c61-0e8e28b73c48%40gmail.com.