Closed zhengxiaochuan-3 closed 6 years ago
Read operations are guaranteed not to modify internal state, so any number of reads can be done concurrently. However, writes do modify internal state, and a write should not be done concurrently with another write OR read.
In your specific case, since you're doing a write you should lock.
In go doc ,says "Write operations are not safe for concurrent mutation by multiple goroutines, but Read operations are."
But I don`t kown is this safe : "only one goroutine put and some other goroutines get" ,should I lock it ?