{"action":"created","issue":{"url":"https://api.github.com/repos/cevaris/ordered_map/issues/4","repository_url":"https://api.github.com/repos/cevaris/ordered_map","labels_url":"https://api.github.com/repos/cevaris/ordered_map/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/cevaris/ordered_map/issues/4/comments","events_url":"https://api.github.com/repos/cevaris/ordered_map/issues/4/events","html_url":"https://github.com/cevaris/ordered_map/issues/4","id":151297570,"number":4,"title":"goroutine leak on early termination of iteration","user":{"login":"campbellr","id":205752,"avatar_url":"https://avatars.githubusercontent.com/u/205752?v=3","gravatar_id":"","url":"https://api.github.com/users/campbellr","html_url":"https://github.com/campbellr","followers_url":"https://api.github.com/users/campbellr/followers","following_url":"https://api.github.com/users/campbellr/following{/other_user}","gists_url":"https://api.github.com/users/campbellr/gists{/gist_id}","starred_url":"https://api.github.com/users/campbellr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/campbellr/subscriptions","organizations_url":"https://api.github.com/users/campbellr/orgs","repos_url":"https://api.github.com/users/campbellr/repos","events_url":"https://api.github.com/users/campbellr/events{/privacy}","received_events_url":"https://api.github.com/users/campbellr/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/cevaris/ordered_map/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-04-27T04:40:35Z","updated_at":"2016-05-11T16:16:39Z","closed_at":"2016-05-11T16:16:39Z","body":"I'm pretty sure that the current implementation of `OrderedMap.Iter` will result in a goroutine leak if the user stops iteration before consuming all values from the channel (either explicitly via a `break` or `return`, or via a `panic`).\r\n\r\nThe easiest solution I can think of to solve this is return two values, the iteration channel and a \"done\" channel.\r\n\r\nFor example (completely contrived):\r\n\r\n```go\r\niter, done := om.Iter()\r\nfor kv := range iter {\r\n    if kv.Value.(string) == \"foobar\" {\r\n        close(done)\r\n        return kv\r\n    }\r\n}\r\n\r\n```\r\n\r\nUnfortunately this makes the API a bit less pleasant..."},"comment":{"url":"https://api.github.com/repos/cevaris/ordered_map/issues/comments/218510312","html_url":"https://github.com/cevaris/ordered_map/issues/4#issuecomment-218510312","issue_url":"https://api.github.com/repos/cevaris/ordered_map/issues/4","id":218510312,"user":{"login":"campbellr","id":205752,"avatar_url":"https://avatars.githubusercontent.com/u/205752?v=3","gravatar_id":"","url":"https://api.github.com/users/campbellr","html_url":"https://github.com/campbellr","followers_url":"https://api.github.com/users/campbellr/followers","following_url":"https://api.github.com/users/campbellr/following{/other_user}","gists_url":"https://api.github.com/users/campbellr/gists{/gist_id}","starred_url":"https://api.github.com/users/campbellr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/campbellr/subscriptions","organizations_url":"https://api.github.com/users/campbellr/orgs","repos_url":"https://api.github.com/users/campbellr/repos","events_url":"https://api.github.com/users/campbellr/events{/privacy}","received_events_url":"https://api.github.com/users/campbellr/received_events","type":"User","site_admin":false},"created_at":"2016-05-11T16:16:39Z","updated_at":"2016-05-11T16:16:39Z","body":"@cevaris Sorry for taking so long to reply, but that looks good to me. Thanks!\r\n\r\nLooks like this can be closed now."}}