Hi Marvin! I am sure it did not detect race immediately at least in my project, which has similar global variable race conditions, but in a more subtle way .
For example, the checking of one global variable is from an incoming message from a remote host, while the changing of the global variable is from a crontask. They have a possibility to collide, but my race build did not crash because of it yet. Zhaoxun 在2022年5月1日星期日 UTC+8 00:18:11<Marvin Renich> 写道: > * Zhaoxun Yan <yan.z...@gmail.com> [220430 02:29]: > > Hi Dan! > > > > I did as you told, but go build -race still not functions: > > No, Dan said you must build with -race and then execute the output from > the build: > > $ go build race race2 > $ ./race2 > > What Dan was saying is that «go build -race» does _not_ detect races > during the build process, but produces an executable that contains the > race detector built-in, so that when you invoke the executable, any > races will be detected. > > > zxun@zxun-virtual:~/src/race2$ go build > > zxun@zxun-virtual:~/src/race2$ ls > > race2 race.go > > zxun@zxun-virtual:~/src/race2$ go build -race race2 > > zxun@zxun-virtual:~/src/race2$ go run -race race.go > > ================== > > WARNING: DATA RACE > [snip] > > Found 1 data race(s) > > exit status 66 > > > > 在2022年4月30日星期六 UTC+8 14:22:26<kortschak> 写道: > > > > > On Fri, 2022-04-29 at 23:18 -0700, Zhaoxun Yan wrote: > > > > And then in that folder you run: > > > > # go build -race > > > > Nothing happens, at least in my go1.15 > > > > > > The race detector needs to run to detect data races; it's not a static > > > analysis tool. > > > > > > So if you execute the binary that you built with `go build -race` you > > > should see the race report. > > > > > > Dan > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/77150944-12e5-441d-8fe0-430f39a2b5cfn%40googlegroups.com.