* Zhaoxun Yan <yan.zhao...@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/Ym1hKW0D2hogcsGb%40basil.wdw.

Reply via email to