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

Display the elements of the structure shown in test condition in their original order #202

Open
k2tzumi opened this issue Oct 10, 2022 · 2 comments

Comments

@k2tzumi
Copy link
Collaborator

k2tzumi commented Oct 10, 2022

For example, if you try to compare the response json, the elements will be sorted and changed from the original response

@k1LoW
Copy link
Owner

k1LoW commented Oct 10, 2022

*.Marshal sorts the elements of JSON/YAML.

e.g. https://github.com/golang/go/blob/213504e5431891e8421a92ab72ac08981ce07516/src/encoding/json/encode.go#L804

On the other hand, in Go, the order of keys in the map is random.
https://go.dev/doc/go1#iteration

I don't think it can be helped that the elements are sorted since to fix the output.

@k2tzumi
Copy link
Collaborator Author

k2tzumi commented Oct 10, 2022

Thanks

golang/go#27179

It seems to be quite difficult.
I have considered whether it is possible to separate the structure of the comparison process from the structure of the output, and would like to continue to consider this.

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