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??