Answer the question
In order to leave comments, you need to log in
Advanced feature for testing aka reflect.DeepEqual?
I need a function to compare two complex nested structures.
`reflect.DeepEqual` basically copes with its mission, but it returns true or false, and I would like to have more detailed information - which field when compared gave the wrong result, what index the structure had if it was inside the slice. Is there something similar already implemented. That is, I need a function that does the same thing as reflect.DeepEqual, but which will return an error with a description of the problem, not true or false.
Maybe there is something already ready, do not want to write another bike.
Answer the question
In order to leave comments, you need to log in
I will advise https://github.com/stretchr/testify
Namely, the assert package, it shows diff structures.
Diff:
--- Expected
+++ Actual
@@ -2,5 +2,5 @@
(int) 1,
- (int) 2,
(int) 3,
- (int) 4
+ (int) 5,
+ (int) 7
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question