You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is not an issue but since I am not sure where to ask this question, I though this would be most ideal place given that the advice is given in this repo. Would be much appreciated if answered/made clearer.
Receiver Type
...
If the receiver is a struct that contains a sync.Mutex or similar synchronizing field, the receiver must be a pointer to avoid copying.
If I a have a struct which contains another struct and that one contains an another ..... (you get what I mean, sub field after sub field), should my struct be a pointer? Or, are we talking about my struct's immediate field, not the sub fields and all that?
Some random example.
typeMyselfstruct {
namestringaddressAddressaccount*Account
}
typeAddressstruct {
linestringcitystringresidents []*Resident
}
typeAccountstruct {
nointbalancestringmux sync.Mutex
}
// Like this?func (mMyself) xyz() {
// m will never be mutated nor its fields
}
// Like this?func (m*Myself) xyz() {
// m will never be mutated nor its fields
}
The text was updated successfully, but these errors were encountered:
@ianlancetaylor Before I go away, based on the example above which one is correct please? Asking because "... other than ..." addition got me confused a bit.
Hi,
This is not an issue but since I am not sure where to ask this question, I though this would be most ideal place given that the advice is given in this repo. Would be much appreciated if answered/made clearer.
Thanks
https://github.com/golang/go/wiki/CodeReviewComments#receiver-type
If I a have a struct which contains another struct and that one contains an another ..... (you get what I mean, sub field after sub field), should my struct be a pointer? Or, are we talking about my struct's immediate field, not the sub fields and all that?
Some random example.
The text was updated successfully, but these errors were encountered: