Skip to content

Commit

Permalink
updates on community convention around mutex naming and position plus…
Browse files Browse the repository at this point in the history
… clarification of release in travis
  • Loading branch information
quii committed Feb 7, 2019
1 parent 83b9531 commit efaff06
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
script:
- go get -u github.com/client9/misspell/cmd/misspell
- misspell -error .
- stage: epub
- stage: releases
script:
- docker pull jagregory/pandoc
- "./build.epub.sh"
Expand Down
27 changes: 26 additions & 1 deletion build.epub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,32 @@

set -e

docker run -v `pwd`:/source jagregory/pandoc -o learn-go-with-tests.epub -o learn-go-with-tests.pdf --latex-engine=xelatex --toc --toc-depth=1 title.txt \
docker run -v `pwd`:/source jagregory/pandoc -o learn-go-with-tests.pdf --latex-engine=xelatex --toc --toc-depth=1 title.txt \
gb-readme.md \
hello-world.md \
integers.md \
arrays-and-slices.md \
structs-methods-and-interfaces.md \
pointers-and-errors.md \
maps.md \
dependency-injection.md \
mocking.md \
concurrency.md \
select.md \
reflection.md \
sync.md \
app-intro.md \
http-server.md \
json.md \
io.md \
command-line.md \
time.md \
websockets.md \
os-exec.md \
error-types.md \
why.md

docker run -v `pwd`:/source jagregory/pandoc -o learn-go-with-tests.epub --latex-engine=xelatex --toc --toc-depth=1 title.txt \
gb-readme.md \
hello-world.md \
integers.md \
Expand Down
8 changes: 4 additions & 4 deletions sync.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,13 @@ A simple solution is to add a lock to our `Counter`, a [`Mutex`](https://golang.
```go
type Counter struct {
mu sync.Mutex
value int
lock sync.Mutex
}

func (c *Counter) Inc() {
c.lock.Lock()
defer c.lock.Unlock()
c.mu.Lock()
defer c.mu.Unlock()
c.value++
}
```
Expand All @@ -187,8 +187,8 @@ You may see examples like this

```go
type Counter struct {
value int
sync.Mutex
value int
}
```

Expand Down
6 changes: 3 additions & 3 deletions sync/v2/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import "sync"

// Counter will increment a number
type Counter struct {
mu sync.Mutex
value int
lock sync.Mutex
}

// NewCounter returns a new Counter
Expand All @@ -15,8 +15,8 @@ func NewCounter() *Counter {

// Inc the count
func (c *Counter) Inc() {
c.lock.Lock()
defer c.lock.Unlock()
c.mu.Lock()
defer c.mu.Unlock()
c.value++
}

Expand Down

0 comments on commit efaff06

Please sign in to comment.