{"action":"created","issue":{"url":"https://api.github.com/repos/gogo/protobuf/issues/125","labels_url":"https://api.github.com/repos/gogo/protobuf/issues/125/labels{/name}","comments_url":"https://api.github.com/repos/gogo/protobuf/issues/125/comments","events_url":"https://api.github.com/repos/gogo/protobuf/issues/125/events","html_url":"https://github.com/gogo/protobuf/issues/125","id":120435521,"number":125,"title":"Asymetric Equal behavior","user":{"login":"dennwc","id":676724,"avatar_url":"https://avatars.githubusercontent.com/u/676724?v=3","gravatar_id":"","url":"https://api.github.com/users/dennwc","html_url":"https://github.com/dennwc","followers_url":"https://api.github.com/users/dennwc/followers","following_url":"https://api.github.com/users/dennwc/following{/other_user}","gists_url":"https://api.github.com/users/dennwc/gists{/gist_id}","starred_url":"https://api.github.com/users/dennwc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dennwc/subscriptions","organizations_url":"https://api.github.com/users/dennwc/orgs","repos_url":"https://api.github.com/users/dennwc/repos","events_url":"https://api.github.com/users/dennwc/events{/privacy}","received_events_url":"https://api.github.com/users/dennwc/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-12-04T16:23:39Z","updated_at":"2015-12-07T15:10:22Z","closed_at":null,"body":"(Copied from #13)\r\nThere is an issue with this combination of options:\r\n```proto\r\nmessage M {\r\n    repeated bytes arr = 1 [(gogoproto.customtype) = \"MyType\", (gogoproto.nullable) = false];\r\n}\r\n```\r\nIt will generate next code for M:\r\n```Go\r\ntype MyType struct{}\r\nfunc (this *MyType) Equal(that interface{}) bool {\r\n    // ...\r\n   that1, ok := that.(*MyType) // auto-generated function assumes pointer to type \r\n    if !ok {\r\n        return false\r\n    }\r\n    // ...\r\n}\r\n\r\ntype M struct {\r\n    Arr []MyType `protobuf:\"bytes,1,rep,name=arr,customtype=MyType\" json:\"arr\"`\r\n}\r\n\r\nfunc (this *M) Equal(that interface{}) bool {\r\n    // ...\r\n    if !this.Arr[i].Equal(that1.Arr[i]) { // should be &that1.Arr[i]\r\n        return false\r\n    }\r\n    // ...\r\n}\r\n```\r\nIt will fail because `Equal` method will try to cast a parameter to `*MyType`. So, the behavior of `Equal` method is asymmetric - it will try to pass an `Arr[i]` element, but their auto-generated versions assumes, that parameter will be a pointer to the type."},"comment":{"url":"https://api.github.com/repos/gogo/protobuf/issues/comments/162551331","html_url":"https://github.com/gogo/protobuf/issues/125#issuecomment-162551331","issue_url":"https://api.github.com/repos/gogo/protobuf/issues/125","id":162551331,"user":{"login":"awalterschulze","id":1829933,"avatar_url":"https://avatars.githubusercontent.com/u/1829933?v=3","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":"2015-12-07T15:10:21Z","updated_at":"2015-12-07T15:10:21Z","body":"It looks like its working\r\nhttps://github.com/gogo/protobuf/commit/e492fd34b12d0230755c45aa5fb1e1eea6a84aa9\r\ncustomtype is supposed to be a type you created yourself and not another protocol buffer.\r\nObviously it can be, but it you will at least need to edit the Marshal method to not have a pointer receiver.\r\nAlso you will need a different NewPopulate method."}}