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

String diff for UUIDs can use strings.Join syntax which makes it more confusing #356

Open
prashantv opened this issue Mar 21, 2024 · 4 comments

Comments

@prashantv
Copy link

prashantv commented Mar 21, 2024

This is a similar topic as #274 and #195, but when using cmp to diff UUIDs.

When the UUIDs are very different, the output looks like:

  	ID: strings.Join({
- 		"e93d2d8b-7d2a-4c62-967a-b189347a4fa2",
+ 		"7e93c401-4e27-3b83-7edc-2dd0803c39b3",
  	}, ""),

The strings.Join adds unnecessary noise here, ideally it would be displayed as:

-  	ID: "e93d2d8b-7d2a-4c62-967a-b189347a4fa2",
+ 	ID: "7e93c401-4e27-3b83-7edc-2dd0803c39b3",

However, if the UUIDs have common characters, the output gets really verbose, and isn't particularly useful:

  	ID: strings.Join({
- 		"217d",
  		"6",
- 		"7ef-d686-4107-ab35-347ed6c91a22",
+ 		"68416ab-a20e-48ae-afaa-8df7b91a4af3",
  	}, ""),

Is there a way to avoid this specialized string handling and have it never use the strings.Join output but show a simpler remove/add for string fields?

@dsnet
Copy link
Collaborator

dsnet commented Mar 21, 2024

Thanks for filing. This is a bug. There are more differences than similarities, that it shouldn't have chosen this particular representation.

@dsnet
Copy link
Collaborator

dsnet commented Mar 21, 2024

For my own benefit, here's a reproduction: https://go.dev/play/p/7u4lcejtNsf

@prashantv
Copy link
Author

Thanks for the additional context. Even in the case that the UUIDs have significant overlap, the strings.Join format is noisy, and causes other issues for code that tries to detect and replace UUIDs.

Ideally we could turn off this feature completely, is there existing options that can be passed to control this behaviour?

@richunger
Copy link

Looks like this was introduced in 0.5.6. Works correctly in 0.5.5.

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

3 participants