News for hackers. Stuff that matters.
Re:Go concurrency isn't parallelism: Real world lessons with... by intortus on Saturday February 07, 2015 @12:06PM (#9014548)
Another error the author made is adding to a sync.WaitGroup in a different goroutine than the one that waits. This is another rookie mistake that go test -race would probably catch.
Re:Go concurrency isn't parallelism: Real world lessons with... by Twirrim on Saturday February 07, 2015 @02:15PM (#9014980)
It does indeed catch it

  $ go test -race -bench=.
  
  ...
  
  WARNING: DATA RACE
  Write by goroutine 4:
    sync.raceWrite()
        /usr/lib/go/src/pkg/sync/race.go:41 +0x35
    sync.(*WaitGroup).Wait()
        /usr/lib/go/src/pkg/sync/waitgroup.go:120 +0x16d
    _/home/twirrim/monte.GetPiMulti()
        /home/twirrim/monte/monte.go:56 +0x23a
    _/home/twirrim/monte.BenchmarkGetPiMulti()
        /home/twirrim/monte/monte_test.go:17 +0x62
    testing.(*B).runN()
        /usr/lib/go/src/pkg/testing/benchmark.go:119 +0xc0
    testing.(*B).launch()
        /usr/lib/go/src/pkg/testing/benchmark.go:207 +0x1ba
  
  ...
And so on.
Re:Go concurrency isn't parallelism: Real world lessons with... by Strom on Saturday February 07, 2015 @12:24PM (#9014597)
Indeed. Additionally, waitgroups aren't even needed, the channel usage in the code is already enough sync.
Re:Go concurrency isn't parallelism: Real world lessons with... by soroushjp on Sunday February 08, 2015 @04:07AM (#9016811)
Fixed, thank you :)