Add comments to indicate it's a bad/good example

Make it more explicit that Counter/Counter2 is a bad/good example. Those without the book
This commit is contained in:
Kenneth Yang 2024-07-15 14:55:19 -04:00 committed by GitHub
parent 9990a8c753
commit 43555f9a77
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -19,7 +19,7 @@ func main() {
}
type Counter struct {
mu sync.Mutex
mu sync.Mutex // bad
counters map[string]int
}
@ -38,7 +38,7 @@ func (c *Counter) Increment2(name string) {
}
type Counter2 struct {
mu *sync.Mutex
mu *sync.Mutex // good
counters map[string]int
}