On Sun, 2 Oct 2022 19:22:21 +1100 Rob Pike <r...@golang.org> wrote: > Apologies, the cover tool calls it -mode but the go command calls it > -covermode. > > go test -covermode=atomic > > -rob > >
Got it, thanks, but it still fail with the data race. ---- (ins) 1 $ GOEXPERIMENT=coverageredesign CGO_ENABLED=1 go test -covermode=atomic -race -coverprofile=cover.out ./lib/dns dns.Server: listening for DNS over UDP at 127.0.0.1:5300 dns.Server: listening for DNS over TCP at 127.0.0.1:5300 dns.Server: listening for DNS over TLS at 127.0.0.1:18053 dns.Server: listening for DNS over HTTPS at 127.0.0.1:8443 dns: invalid IP address "localhost" dns: invalid name server URI "://127.0.0.1" dns: invalid IP address "localhost:53" dns: invalid IP address "localhost:53" PASS ================== WARNING: DATA RACE Read at 0x000001e5f04c by main goroutine: internal/coverage/encodecounter.(*CoverageDataWriter).writeCounters.func2() /home/ms/opt/go/src/internal/coverage/encodecounter/encode.go:261 +0x11c runtime/coverage.(*emitState).VisitFuncs() /home/ms/opt/go/src/runtime/coverage/emit.go:539 +0x6bc internal/coverage/encodecounter.(*CoverageDataWriter).writeCounters() /home/ms/opt/go/src/internal/coverage/encodecounter/encode.go:268 +0x16f ... Found 12 data race(s) FAIL github.com/shuLhan/share/lib/dns 0.754s FAIL ---- BTW, from documentation, the -race flag automatically set the -covermode=atomic. -covermode set,count,atomic ... being tested. The default is "set" unless -race is enabled, in which case it is "atomic". ... So I think its redundant to set -race and -covermode=atomic at the same time. -- 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/20221002154034.3ea7e088%40inspiro.localdomain.
pgpnCXCcVut4T.pgp
Description: OpenPGP digital signature