You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can embed a Cond value in another struct (what the docs are saying?), but the zero value is not valid. You must initialize the Locker.
bradfitz
changed the title
sync: nil pointer with Cond created as part of struct
sync: clarify Cond "created as part of other structures" documentation
May 23, 2017
Before we close this, is it possible to add a panic if L is nil with more descriptive error? Nil pointer dereference is panic anyway already. I guess more a philosophical thing if things should check for things if used against doc. Looking at the existing copy checker, I think yes.
Further, I guess an example would be good to include, never too many examples?
What version of Go are you using (
go version
)?go version go1.8.1 darwin/amd64
What operating system and processor architecture are you using (
go env
)?What did you do?
I'm creating a sync.Cond as part of a struct. Documentation explicitly says this is ok.
https://play.golang.org/p/k0EkYJPC4A
What did you expect to see?
Wait for Cond until Broadcast is called one second later.
What did you see instead?
There isn't an example for sync.Cond in the documentation and it's hardly used in the standard library.
Should the documentation explain that the locker must be set if the Cond is created as part of a structure? If yes, then what does this really mean:
Please update title if this turns out to be a documentation issue. A simple example and where the Cond might be useful would be nice.
The text was updated successfully, but these errors were encountered: