a consequence, although GDB can be useful in some situations, it is not a reliable debugger for Go programs, particularly heavily concurrent ones. Moreover, it is not a priority for the Go project to address these issues, which are difficult. In short, the instructions below should be taken only as a guide to how to use GDB when it works, not as a guarantee of success. In time, a more Go-centric debugging architecture may be required. …
WARNING: DATA RACE Write by goroutine 4: main.func·001() /home/sat/gopath/src/test/race/race.go:7 +0x43 Previous write by main goroutine: main.main() /home/sat/gopath/src/test/race/race.go:10 +0x176 Goroutine 4 (running) created at: main.main() /home/sat/gopath/src/test/race/race.go:9 +0x166 ================== Found 1 data race(s) exit status 66 1 package main 2 3 func main() { 4 c := make(chan bool) 5 i := 0 6 go func() { 7 i = 1 8 c <- true 9 }() 10 i = 2 11 <- c 12} この時点でiが1か2か不定。 言い換えると、7行目と10行目の どちらが先に実行されるか不定 7行目と10行目の競合を検出
“Installation”の欄にソース取得コマンドしか記載が無いが、実 際にgodebugプログラムを使用するには、以下コマンドの実 行が必要 1. go get github.com/mailgun/godebug 2. cd $GOPATH/src/github.com/mailgun/godebug 3. go install # これで$GOPATH/bin以下にgodebugがインストールされる • 本書執筆時点では機能が非常に少ない(gdb未満) • まだプロジェクトが新しいので、将来に期待か