{"action":"created","issue":{"url":"https://api.github.com/repos/golang/go/issues/27808","repository_url":"https://api.github.com/repos/golang/go","labels_url":"https://api.github.com/repos/golang/go/issues/27808/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/27808/comments","events_url":"https://api.github.com/repos/golang/go/issues/27808/events","html_url":"https://github.com/golang/go/issues/27808","id":362798279,"node_id":"MDU6SXNzdWUzNjI3OTgyNzk=","number":27808,"title":"ref/mem: misleading sentence in sync.Once example","user":{"login":"seebs","id":166725,"node_id":"MDQ6VXNlcjE2NjcyNQ==","avatar_url":"https://avatars1.githubusercontent.com/u/166725?v=4","gravatar_id":"","url":"https://api.github.com/users/seebs","html_url":"https://github.com/seebs","followers_url":"https://api.github.com/users/seebs/followers","following_url":"https://api.github.com/users/seebs/following{/other_user}","gists_url":"https://api.github.com/users/seebs/gists{/gist_id}","starred_url":"https://api.github.com/users/seebs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seebs/subscriptions","organizations_url":"https://api.github.com/users/seebs/orgs","repos_url":"https://api.github.com/users/seebs/repos","events_url":"https://api.github.com/users/seebs/events{/privacy}","received_events_url":"https://api.github.com/users/seebs/received_events","type":"User","site_admin":false},"labels":[{"id":150880209,"node_id":"MDU6TGFiZWwxNTA4ODAyMDk=","url":"https://api.github.com/repos/golang/go/labels/Documentation","name":"Documentation","color":"aaffaa","default":false},{"id":373399998,"node_id":"MDU6TGFiZWwzNzMzOTk5OTg=","url":"https://api.github.com/repos/golang/go/labels/NeedsFix","name":"NeedsFix","color":"ededed","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/golang/go/milestones/65","html_url":"https://github.com/golang/go/milestone/65","labels_url":"https://api.github.com/repos/golang/go/milestones/65/labels","id":3072996,"node_id":"MDk6TWlsZXN0b25lMzA3Mjk5Ng==","number":65,"title":"Go1.12","description":"","creator":{"login":"rsc","id":104030,"node_id":"MDQ6VXNlcjEwNDAzMA==","avatar_url":"https://avatars1.githubusercontent.com/u/104030?v=4","gravatar_id":"","url":"https://api.github.com/users/rsc","html_url":"https://github.com/rsc","followers_url":"https://api.github.com/users/rsc/followers","following_url":"https://api.github.com/users/rsc/following{/other_user}","gists_url":"https://api.github.com/users/rsc/gists{/gist_id}","starred_url":"https://api.github.com/users/rsc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rsc/subscriptions","organizations_url":"https://api.github.com/users/rsc/orgs","repos_url":"https://api.github.com/users/rsc/repos","events_url":"https://api.github.com/users/rsc/events{/privacy}","received_events_url":"https://api.github.com/users/rsc/received_events","type":"User","site_admin":false},"open_issues":717,"closed_issues":194,"state":"open","created_at":"2018-01-29T21:17:52Z","updated_at":"2018-09-22T02:10:32Z","due_on":"2019-01-31T08:00:00Z","closed_at":null},"comments":3,"created_at":"2018-09-21T22:58:54Z","updated_at":"2018-09-22T02:17:33Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"### What version of Go are you using (`go version`)?\r\n\r\n1.11/playground\r\n\r\n### Does this issue reproduce with the latest release?\r\n\r\nyes\r\n\r\n### What operating system and processor architecture are you using (`go env`)?\r\n\r\nlinux/amd64, playground\r\n\r\n### What did you do?\r\n\r\nhttps://play.golang.org/p/w-CNHDQAGW-\r\n\r\n### What did you expect to see?\r\n\r\naccording to ref/mem as written, \"1\\n1 hello, 1\\n2\\n 2 hello 1\\n\"\r\n\r\n### What did you see instead?\r\n\r\nthe other way around\r\n\r\nObservation: There's two things here that I think are potentially misleading, although both are sort of trivial. The first is that, according to the \"goroutine destruction\" section, there's no guarantee that *anything* gets printed, because nothing is waiting on these, and indeed, without the extra channel operations, nothing happens.\r\n\r\nThe second is the distinction between \"the first call to doprint()\", \"the first call to doprint() which actually starts execution\", and \"the first call to doprint() which actually begins the once.Do() call\". While in the trivial example, probably the first call to start executing will win that, it's not generally a given that two goroutines acting in parallel will always complete in the same order they start, even running identical code. But in particular, it's definitely not guaranteed that the \"first call\" will start executing first.\r\n\r\nI'm fine with handwaving the synchronization thing, but I think the wording on \"the first call\" might benefit from cleaning up. Proposed wording:\r\n\r\nThe first call to `doprint()` to begin executing the `once.Do()` calls `setup()`, any calls that reach that point later do not, regardless of the order in which the goroutines are invoked or begin executing."},"comment":{"url":"https://api.github.com/repos/golang/go/issues/comments/423709980","html_url":"https://github.com/golang/go/issues/27808#issuecomment-423709980","issue_url":"https://api.github.com/repos/golang/go/issues/27808","id":423709980,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMzcwOTk4MA==","user":{"login":"seebs","id":166725,"node_id":"MDQ6VXNlcjE2NjcyNQ==","avatar_url":"https://avatars1.githubusercontent.com/u/166725?v=4","gravatar_id":"","url":"https://api.github.com/users/seebs","html_url":"https://github.com/seebs","followers_url":"https://api.github.com/users/seebs/followers","following_url":"https://api.github.com/users/seebs/following{/other_user}","gists_url":"https://api.github.com/users/seebs/gists{/gist_id}","starred_url":"https://api.github.com/users/seebs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seebs/subscriptions","organizations_url":"https://api.github.com/users/seebs/orgs","repos_url":"https://api.github.com/users/seebs/repos","events_url":"https://api.github.com/users/seebs/events{/privacy}","received_events_url":"https://api.github.com/users/seebs/received_events","type":"User","site_admin":false},"created_at":"2018-09-22T02:17:33Z","updated_at":"2018-09-22T02:17:33Z","author_association":"CONTRIBUTOR","body":"That's a good point. I'm pondering this, because I think there's a mild ambiguity there, but on reflection, I think it's just the general ambiguity that nothing promises that code ever executes at all. For instance, so far as I can tell, if a hostile implementor looked at the sample code, and decided that they could prove that two things would eventually reach the once.Do(), they would be allowed to implement it so that the *first* goroutine to reach that point necessarily blocks, and the *second* is allowed to run the provided function. But I guess that doesn't actually matter at all, as long as they don't block indefinitely for no particular reason.\r\n\r\nHmm.\r\n\r\nCome to think of it:\r\n\r\n> Multiple threads can execute `once.Do(f)` for a particular `f`, but only one will run `f()`, and the other calls block until f() has returned. \r\n\r\nShouldn't that be \"for a particular `once`\"?\r\n\r\n```\r\n\tswitch(i) {\r\n\tcase 1: once.Do(one)\r\n\tcase 2: once.Do(two)\r\n\t}\r\n```"}}
{"actor":{"display_login":"seebs"}}