Skip to content

Commit 0a3ecd3

Browse files
authored
Fix Diff documentation (#237)
The description inaccurately describes the operation of Diff, which is y - x, where a '+' prefix denotes elements added from y and a '-' prefix denotes elements removed from x. For example: // Consider this call to Diff and its result. x y cmp.Diff({b:2, c:3}, {a:1, b:2}) => {+a:1, b:2, -c:3} // Consider the same in mathematical notation. y - x {a:1, b:2} - {b:2, c:3} = {+a:1, b:2, -c:3}
1 parent d3c8501 commit 0a3ecd3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

cmp/compare.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ func Equal(x, y interface{}, opts ...Option) bool {
100100
// same input values and options.
101101
//
102102
// The output is displayed as a literal in pseudo-Go syntax.
103-
// At the start of each line, a "-" prefix indicates an element removed from y,
104-
// a "+" prefix to indicates an element added to y, and the lack of a prefix
103+
// At the start of each line, a "-" prefix indicates an element removed from x,
104+
// a "+" prefix to indicates an element added from y, and the lack of a prefix
105105
// indicates an element common to both x and y. If possible, the output
106106
// uses fmt.Stringer.String or error.Error methods to produce more humanly
107107
// readable outputs. In such cases, the string is prefixed with either an

0 commit comments

Comments
 (0)