We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
package playground_test import ( "testing" "github.com/agiledragon/gomonkey/v2" "github.com/stretchr/testify/assert" "golang.org/x/sync/errgroup" ) func foo() int { return 0 } func run() error { var eg errgroup.Group eg.Go(func() error { foo() return nil }) eg.Go(func() error { foo() return nil }) if err := eg.Wait(); err != nil { return err } return nil } func TestPlayground(t *testing.T) { assert := assert.New(t) patches := gomonkey.NewPatches() defer patches.Reset() patches.ApplyFuncSeq(foo, []gomonkey.OutputCell{ { Values: gomonkey.Params{1}, }, { Values: gomonkey.Params{2}, }, }) err := run() assert.Nil(err) }
run with go test -race -gcflags=all=-l, would get the following error
go test -race -gcflags=all=-l
================== WARNING: DATA RACE Read at 0x00c000222d88 by goroutine 8: github.com/agiledragon/gomonkey/v2.getDoubleFunc.func1() /data00/home/liuqi.victor/go/pkg/mod/github.com/agiledragon/gomonkey/[email protected]/patch.go:304 +0xde reflect.callReflect() /data00/home/liuqi.victor/opt/go/src/reflect/value.go:770 +0x762 reflect.callReflect() <autogenerated>:1 +0x64 reflect.makeFuncStub() /data00/home/liuqi.victor/opt/go/src/reflect/asm_amd64.s:47 +0x79 golang.org/x/sync/errgroup.(*Group).Go.func1() /data00/home/liuqi.victor/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:75 +0x86 Previous write at 0x00c000222d88 by goroutine 9: github.com/agiledragon/gomonkey/v2.getDoubleFunc.func1() /data00/home/liuqi.victor/go/pkg/mod/github.com/agiledragon/gomonkey/[email protected]/patch.go:305 +0x108 reflect.callReflect() /data00/home/liuqi.victor/opt/go/src/reflect/value.go:770 +0x762 reflect.callReflect() <autogenerated>:1 +0x64 reflect.makeFuncStub() /data00/home/liuqi.victor/opt/go/src/reflect/asm_amd64.s:47 +0x79 golang.org/x/sync/errgroup.(*Group).Go.func1() /data00/home/liuqi.victor/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:75 +0x86
The text was updated successfully, but these errors were encountered:
No branches or pull requests
run with
go test -race -gcflags=all=-l
, would get the following errorThe text was updated successfully, but these errors were encountered: