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

[refactor] Don't use go-cmp in non-test code. #642

Closed
ianlewis opened this issue Jun 19, 2023 · 0 comments
Closed

[refactor] Don't use go-cmp in non-test code. #642

ianlewis opened this issue Jun 19, 2023 · 0 comments
Labels
type:refactor A cleanup or refactor

Comments

@ianlewis
Copy link
Member

Currently we use go-cmp for non-test code in some verification logic. Since go-cmp is meant to be used in tests, I think we should avoid using it in non-test code.

@ianlewis ianlewis added the type:refactor A cleanup or refactor label Jun 19, 2023
ramonpetgrave64 added a commit to ramonpetgrave64/slsa-verifier that referenced this issue Jan 17, 2024
Previously we used the go-cmp's Diff for displaying a human-friendly diff between two structs in an error message.

I had intended to do a json print of the structs and do a line-by-line diff. There is an internal library for calculating text diff, but I don't see any external functions that expose it:
https://pkg.go.dev/golang.org/x/tools/internal/diff

Instead, this we will simply display both structs in their own "actual" and "expected" sections. The user can use their other tools to find a human-friendly diff.

Signed-off-by: Ramon Petgrave <ramon.petgrave64@gmail.com>
ramonpetgrave64 added a commit to ramonpetgrave64/slsa-verifier that referenced this issue Apr 10, 2024
…ramework#737)

Previously we used the go-cmp's Diff for displaying a human-friendly
diff between two structs in an error message.

I had intended to do a json print of the structs and do a line-by-line
diff. There is an internal library for calculating text diff, but I
don't see any external functions that expose it to make it available for
our use: https://pkg.go.dev/golang.org/x/tools/internal/diff

Instead, this we will simply display both structs in their own "actual"
and "expected" sections. The user can use their other tools to find a
human-friendly diff.

Signed-off-by: Ramon Petgrave <ramon.petgrave64@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:refactor A cleanup or refactor
Projects
None yet
Development

No branches or pull requests

1 participant