Skip to content
New issue

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

1 data race while running the example code #2

Closed
vjeantet opened this issue Feb 28, 2015 · 1 comment
Closed

1 data race while running the example code #2

vjeantet opened this issue Feb 28, 2015 · 1 comment

Comments

@vjeantet
Copy link

Hello,

I ran
$ go run -race main.go

main.go is the example code found in README

Bellow is the output with the datarace

4
4
==================
WARNING: DATA RACE
Read by goroutine 8:
  github.com/pedronasser/go-piper/piper.(*Pipe).Closed()
      /Users/sodadi/go/src/github.com/pedronasser/go-piper/piper/piper.go:309 +0x3b
  github.com/pedronasser/go-piper/piper.func·001()
      /Users/sodadi/go/src/github.com/pedronasser/go-piper/piper/piper.go:160 +0x447

Previous write by goroutine 5:
  github.com/pedronasser/go-piper/piper.(*Pipe).Close()
      /Users/sodadi/go/src/github.com/pedronasser/go-piper/piper/piper.go:304 +0x3b
  github.com/pedronasser/go-piper/piper.func·001()
      /Users/sodadi/go/src/github.com/pedronasser/go-piper/piper/piper.go:162 +0x4b2

Goroutine 8 (running) created at:
  github.com/pedronasser/go-piper/piper.(*Piper).runPipe()
      /Users/sodadi/go/src/github.com/pedronasser/go-piper/piper/piper.go:168 +0x3f5
  github.com/pedronasser/go-piper/piper.(*Piper).run()
      /Users/sodadi/go/src/github.com/pedronasser/go-piper/piper/piper.go:125 +0x3a0
  github.com/pedronasser/go-piper/piper.newPiper()
      /Users/sodadi/go/src/github.com/pedronasser/go-piper/piper/piper.go:74 +0x3d5
  github.com/pedronasser/go-piper/piper.New()
      /Users/sodadi/go/src/github.com/pedronasser/go-piper/piper/piper.go:50 +0x70
  main.main()
      /Users/sodadi/go/src/home/test-gopipe/main.go:22 +0x260

Goroutine 5 (finished) created at:
  github.com/pedronasser/go-piper/piper.(*Piper).runPipe()
      /Users/sodadi/go/src/github.com/pedronasser/go-piper/piper/piper.go:168 +0x3f5
  github.com/pedronasser/go-piper/piper.(*Piper).run()
      /Users/sodadi/go/src/github.com/pedronasser/go-piper/piper/piper.go:125 +0x3a0
  github.com/pedronasser/go-piper/piper.newPiper()
      /Users/sodadi/go/src/github.com/pedronasser/go-piper/piper/piper.go:74 +0x3d5
  github.com/pedronasser/go-piper/piper.New()
      /Users/sodadi/go/src/github.com/pedronasser/go-piper/piper/piper.go:50 +0x70
  main.main()
      /Users/sodadi/go/src/home/test-gopipe/main.go:22 +0x260
==================
Found 1 data race(s)
exit status 66

@pedronasser
Copy link
Owner

Sorry, forgot to test for race last time.
Just added a mutex to the Pipe struct and problem solved.
Thank you for the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants