On 8 Jan 2018, at 23:35, matthewju...@gmail.com<mailto:matthewju...@gmail.com> 
wrote:

sync.RWMutex works well as an embedded struct field. Locking DB could be 
db.Lock() instead of db.mu.Lock(), and the same could apply to other fields.

This is a common suggestion. I’ve never been very fond of it in general, as it 
makes Lock()/Unlock() part of the exported API of the type. Unless you want 
your API consumers to call Lock() and Unlock() it’s usually better as a 
regular, non-exported field, imho.

(I haven’t looked at the specific code in this case; it’s just the second time 
in a couple of days this suggestion pops up. :)

//jb

-- 
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 golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to