tour: Rename mux -> mu to follow convention
Nearly all sync.Mutex members in the standard library are named mu,
or use "mu" as part of the name. While this isn't a documented
recommendation anywhere that I can find, it would seem nice to start
new users with this same convention.
Change-Id: I67cbe2a0052b81d8bb57d5ece0cefd2f3838f298
GitHub-Last-Rev: 31ef869d9b72e7eb08b9be9340242b0e535a175f
GitHub-Pull-Request: golang/tour#813
Reviewed-on: https://go-review.googlesource.com/c/tour/+/192725
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
diff --git a/content/concurrency/mutex-counter.go b/content/concurrency/mutex-counter.go
index ed727bd..b1483d6 100644
--- a/content/concurrency/mutex-counter.go
+++ b/content/concurrency/mutex-counter.go
@@ -10,23 +10,23 @@
// SafeCounter is safe to use concurrently.
type SafeCounter struct {
- v map[string]int
- mux sync.Mutex
+ mu sync.Mutex
+ v map[string]int
}
// Inc increments the counter for the given key.
func (c *SafeCounter) Inc(key string) {
- c.mux.Lock()
+ c.mu.Lock()
// Lock so only one goroutine at a time can access the map c.v.
c.v[key]++
- c.mux.Unlock()
+ c.mu.Unlock()
}
// Value returns the current value of the counter for the given key.
func (c *SafeCounter) Value(key string) int {
- c.mux.Lock()
+ c.mu.Lock()
// Lock so only one goroutine at a time can access the map c.v.
- defer c.mux.Unlock()
+ defer c.mu.Unlock()
return c.v[key]
}