浏览 236
分享
Zero-value Mutexes are Valid
The zero-value of sync.Mutex
and sync.RWMutex
is valid, so you almostnever need a pointer to a mutex.
Bad | Good |
---|---|
|
|
If you use a struct by pointer, then the mutex can be a non-pointer field.
Unexported structs that use a mutex to protect fields of the struct may embedthe mutex.
|
|
Embed for private types or types that need to implement the Mutex interface. | For exported types, use a private field. |
评论列表