{"action":"created","issue":{"url":"https://api.github.com/repos/gogo/protobuf/issues/431","repository_url":"https://api.github.com/repos/gogo/protobuf","labels_url":"https://api.github.com/repos/gogo/protobuf/issues/431/labels{/name}","comments_url":"https://api.github.com/repos/gogo/protobuf/issues/431/comments","events_url":"https://api.github.com/repos/gogo/protobuf/issues/431/events","html_url":"https://github.com/gogo/protobuf/issues/431","id":342745347,"node_id":"MDU6SXNzdWUzNDI3NDUzNDc=","number":431,"title":"Generated test structs seem to generate useful structs a low amount of time","user":{"login":"heedson","id":7850653,"node_id":"MDQ6VXNlcjc4NTA2NTM=","avatar_url":"https://avatars2.githubusercontent.com/u/7850653?v=4","gravatar_id":"","url":"https://api.github.com/users/heedson","html_url":"https://github.com/heedson","followers_url":"https://api.github.com/users/heedson/followers","following_url":"https://api.github.com/users/heedson/following{/other_user}","gists_url":"https://api.github.com/users/heedson/gists{/gist_id}","starred_url":"https://api.github.com/users/heedson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heedson/subscriptions","organizations_url":"https://api.github.com/users/heedson/orgs","repos_url":"https://api.github.com/users/heedson/repos","events_url":"https://api.github.com/users/heedson/events{/privacy}","received_events_url":"https://api.github.com/users/heedson/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-07-19T14:11:26Z","updated_at":"2018-07-19T14:19:39Z","closed_at":null,"author_association":"NONE","body":"Generated test structs seem to generate useful structs a low amount of time.\r\n---\r\n\r\nIn the `NewPopulatedStruct(...)` method, the if check is inverted from what would make more logical sense compared to other generated code for the same sort of logic. This also creates the situation that means that the most useful case is only chosen 1/10th of the time.\r\nhttps://github.com/gogo/protobuf/blob/master/types/struct.pb.go#L994\r\n```go\r\n\tif r.Intn(10) == 0 {\r\n\t\tv1 := r.Intn(10)\r\n\t\tthis.Fields = make(map[string]*Value)\r\n\t\tfor i := 0; i < v1; i++ {\r\n\t\t\tthis.Fields[randStringStruct(r)] = NewPopulatedValue(r, easy)\r\n\t\t}\r\n\t}\r\n```\r\n`if r.Intn(10) == 0 {` seems like the opposite, especially considering the following if is `if !easy && r.Intn(10) != 0 {`.\r\n\r\nIn a personally generated file, my population method *does* have the inverse check.\r\n```go\r\n\tif r.Intn(10) != 0 {\r\n\t\tthis.Foo = google_protobuf2.NewPopulatedStruct(r, easy)\r\n\t}\r\n```\r\nClarification would be useful to know whether this is the desired effect or if the equality check should be negated."},"comment":{"url":"https://api.github.com/repos/gogo/protobuf/issues/comments/406292775","html_url":"https://github.com/gogo/protobuf/issues/431#issuecomment-406292775","issue_url":"https://api.github.com/repos/gogo/protobuf/issues/431","id":406292775,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNjI5Mjc3NQ==","user":{"login":"awalterschulze","id":1829933,"node_id":"MDQ6VXNlcjE4Mjk5MzM=","avatar_url":"https://avatars3.githubusercontent.com/u/1829933?v=4","gravatar_id":"","url":"https://api.github.com/users/awalterschulze","html_url":"https://github.com/awalterschulze","followers_url":"https://api.github.com/users/awalterschulze/followers","following_url":"https://api.github.com/users/awalterschulze/following{/other_user}","gists_url":"https://api.github.com/users/awalterschulze/gists{/gist_id}","starred_url":"https://api.github.com/users/awalterschulze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/awalterschulze/subscriptions","organizations_url":"https://api.github.com/users/awalterschulze/orgs","repos_url":"https://api.github.com/users/awalterschulze/repos","events_url":"https://api.github.com/users/awalterschulze/events{/privacy}","received_events_url":"https://api.github.com/users/awalterschulze/received_events","type":"User","site_admin":false},"created_at":"2018-07-19T14:19:39Z","updated_at":"2018-07-19T14:19:39Z","author_association":"MEMBER","body":"If you can think of a better way, without breaking the API to generate more useful tree types, then I would also love to use it."}}
{"actor":{"display_login":"awalterschulze"}}