Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go-cmp should ignore generated proto fields #153

Closed
aysylu opened this issue Aug 7, 2019 · 3 comments
Closed

go-cmp should ignore generated proto fields #153

aysylu opened this issue Aug 7, 2019 · 3 comments

Comments

@aysylu
Copy link

aysylu commented Aug 7, 2019

XXX_cachesize auto-generated proto fields are not currently ignored by go-cmp. Example from Grafeas:

storage_test.go:287: GetOccurrence returned diff (want -> got):
            {*grafeas_go_proto.Occurrence}.Resource.XXX_sizecache:
            	-: 0
            	+: 16
            {*grafeas_go_proto.Occurrence}.Details.Vulnerability.PackageIssue[0].AffectedLocation.Version.XXX_sizecache:
            	-: 0
            	+: 16
            {*grafeas_go_proto.Occurrence}.Details.Vulnerability.PackageIssue[0].AffectedLocation.XXX_sizecache:
            	-: 0
            	+: 53
            {*grafeas_go_proto.Occurrence}.Details.Vulnerability.PackageIssue[0].FixedLocation.Version.XXX_sizecache:
            	-: 0
            	+: 16
            {*grafeas_go_proto.Occurrence}.Details.Vulnerability.PackageIssue[0].FixedLocation.XXX_sizecache:
            	-: 0
            	+: 53
            {*grafeas_go_proto.Occurrence}.Details.Vulnerability.PackageIssue[0].XXX_sizecache:
            	-: 0
            	+: 116
            {*grafeas_go_proto.Occurrence}.Details.Vulnerability.XXX_sizecache:
            	-: 0
            	+: 125
            {*grafeas_go_proto.Occurrence}.XXX_sizecache:
            	-: 0
            	+: 307
@dsnet
Copy link
Collaborator

dsnet commented Aug 7, 2019

It doesn't scale if cmp is taught the special case for every possible Go type that exists out there.

What you want is golang/protobuf#762

@dsnet dsnet closed this as completed Aug 7, 2019
@aysylu
Copy link
Author

aysylu commented Aug 7, 2019

Thanks for referencing the relevant issue! Just to clarify: XXX_cachesize isn't about Go types, but about proto fields. The Grafeas type here is just used for example, it's unrelated to the Grafeas itself.

@dsnet
Copy link
Collaborator

dsnet commented Aug 7, 2019

My point is that the presence of XXX_cachesize is an artifact of protobuf message implementations. cmp should not have any knowledge about these special cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants