4 ms·
> Never do this on an exported type. If you embed sync.Mutex that makes "Lock" and "Unlock" part of your exported interface. Now the caller of your API doesn't
by meddlepal 7y ago
> Never do this on an exported type. If you embed sync.Mutex that makes "Lock" and "Unlock" part of your exported interface. Now the caller of your API doesn't know if they are supposed to call Lock/Unlock, or if this is a pure internal implementation detail.
Isn't that exactly what they say?
> Embed for private types or types that need to implement the Mutex interface.
Personally, I would never embed a sync.Mutex though because even for an internal type it is confusing.
- knorker 7y agoCurious. Under "Returning Slices and Maps" they use it in their "Good" example.