diff --git a/.travis.yml b/.travis.yml index 32d250cbf..84ea4e39d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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" diff --git a/build.epub.sh b/build.epub.sh index d4ebd3d81..4b145817f 100755 --- a/build.epub.sh +++ b/build.epub.sh @@ -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 \ diff --git a/sync.md b/sync.md index 3cac97484..fe5f7f994 100644 --- a/sync.md +++ b/sync.md @@ -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++ } ``` @@ -187,8 +187,8 @@ You may see examples like this ```go type Counter struct { - value int sync.Mutex + value int } ``` diff --git a/sync/v2/sync.go b/sync/v2/sync.go index 1fcd9f0b7..a7d8a16f0 100644 --- a/sync/v2/sync.go +++ b/sync/v2/sync.go @@ -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 @@ -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++ }