Changelog History
Page 1
-
v0.5.4 Changes
November 24, 2020 -
v0.5.3 Changes
November 12, 2020 -
v0.5.2 Changes
August 25, 2020 -
v0.5.1 Changes
July 21, 2020 -
v0.5.0 Changes
June 18, 2020๐ The most notable changes in this release are improvements to the reporter output (i.e., the implementation that produces output for
Diff
). The changes seek to improve the signal-to-noise ratio such that differences of interest to the user are emphasized, while information that is less relevant are de-emphasized.๐ The reporter largely consists of a set of heuristics to determine what would be the best way to format the difference in the common case. If the output seems sub-par, please file an issue. The reports are highly valuable in improving its output (e.g., #195, #194, #202, #185).
Reporter changes:
- (#201) Do not use custom format for nil slice. Previously, the reporter had a bug (#157) where it would fail to print the difference between empty slices that were nil versus non-nil, which is now fixed by this change.
- ๐ (#212) Use custom triple-quote syntax for diffing string literals. This adds another way that strings are displayed. Previously, the reporter used a
strings.Join({...}, "\n")
syntax to show diffs between lines within a string. While this representation is unambiguous, the need to escape every line made the output visually distracting. Now, we add a new syntax where multiple lines are represented by a literal syntax using"""
as delimiters. When possible, this syntax is preferred if it can unambiguously represent the difference. - (#208) Batch reporter output for simple lists of text elements. Previously, when formatting a slice of primitives, the reporter would print each element on a new line, causing the output to be long. Now, multiple elements are batched together into a single line to keep the output more dense.
- ๐ (#210) Allow batched diffing of slices with a custom comparer. As a performance optimization, a user may choose to pass
cmp.Comparer(bytes.Equal)
so that large byte slices are compared using an efficient implementation. Previously, this would prevent the reporter from being able to use specialized logic to show the per-element difference between these two slices if they were different, but now it is able to. - (#213, #215) Limit verbosity of reporter output. For slices, maps, and structs, the reporter now imposes a limit on the number of elements, entries, and structs that it will print. The limit is chosen based on heuristics such as the depth of the tree and also whether the node represents an equal value or not, where inequal values are given a larger verbosity budget.
- (#216) Disambiguate reporter output. Previously, there were certain edge cases where the reporter output failed to show a difference between two values that the comparer determined to be different. Now, the reporter works harder to ensure that the output is guaranteed to be different if a semantic difference is there. For example, it may try increasing the verbosity limit, printing pointer addresses, avoid calling the
String
method, using fully qualified type names, or some combination of the above. - ๐ (#217) Improve reporting of values with cycles. Previously, the reporter would simply truncate the result if it ever detected a cycle. While this prevents a stack overflow trying to print a graph, it failed to properly show the topology of the graph. Now, the reporter additionally provides reference markers so that the user can visually identify where a pointer refers to in the output.
- (1776240) Forcibly export fields for use by the reporter. This allows the reporter to use the
String
orError
method (if available) to format values within unexported fields. This occurs regardless of whether anycmp.Exporter
orcmp.AllowUnexported
options are used or not. - ๐ (#210) Use raw string literal syntax only for valid UTF-8. This fixes a minor bug in the reporter to ensure that the output is always valid UTF-8.
๐ Feature changes:
- (#203) Permit use of IgnoreFields with unexported fields. The
cmpopts.IgnoreFields
option now accepts unexported field names. Unlike exported fields, unexported field must be explicit specified as they do not respect forwarding due to struct embedding.
Comparer changes:
- โก๏ธ (#204) Optimize Diff for frequent equality. The
cmp
package is intended for use primarily within tests where the expected outcome is generally equality. Previously, even if the result is equal,cmp.Diff
would construct an expensive diff tree only to discard the result since the values are equal. Now, optimize for the common case by first checking whether the values are equal first, and only construct a diff if they are not. - (#214) Introduce deliberate instability to difference output. The internal algorithm used for diffing elements of a slice is sub-optimal. It does not produce an optimal edit script (i.e., one with the fewest possible reported differences), but is guaranteed to run in O(n). To keep the future open for algorithmic improvements, introduce some degree of deliberate instability so that users do not accidentally rely on it's output being stable.
- (#206) Avoid leaking implementation details of the exporter. In order for the current implementation to forcibly access unexported fields using
unsafe
, it requires that the parent struct be addressable. In Go, a struct field is only addressable if and only if the parent struct is addressable. To avoid leaking this internal implementation detail, we shallow copy the result to remove properties of addressability.
-
v0.4.1 Changes
May 15, 2020 -
v0.4.0 Changes
January 07, 2020โ Added features:
- (#85) The comparison logic now has cycle detection and can now handle graphs.
- (#176) The
cmp.Exporter
option provides finer-grained control over exactly what types to permit unexported field access on. - (#158)
cmpopts.EquateApproxTime
provides the ability to compare timestamps with looser precision. - (#178)
cmpopts.EquateErrors
provides the ability to compare error values using the newerrors.Is
semantics from Go 1.13.
๐ Bug fixes:
- ๐ (#169) Use of
unsafe.Pointer
has been fixed to comply with stricter pointer rules for Go 1.14.
-
v0.3.1 Changes
August 07, 2019๐ Minor reporter fixes:
- ๐ (#142) Fixed reporter to invoke the
String
method when formatting map keys. - ๐ (#148) Fixed reporter to properly elide a struct field on the right side if it is a zero value.
- ๐ (#147) Fixed reporter to avoid diffing by lines if any line exceeds a certain maximum length.
- (#152) Fixed reporter to properly treat -0.0 as not being the zero value.
- ๐ (#142) Fixed reporter to invoke the
-
v0.3.0 Changes
April 29, 2019โ Added features:
- (#108) The
_
field is always ignored when comparing a struct. - (#109) The naming rules for
cmp.Transformer
is relaxed and clearly specified. - (#82)
cmpopts.AcyclicTransformer
makes it easier to write a transformer that avoids infinite recursion when the output type contains the input type. - (#126)
cmpopts.IgnoreSliceElements
andcmpopts.IgnoreMapEntries
provide the ability to ignore specific slice elements or map entries. - (#123)
cmp.Reporter
provides users the ability to add custom difference reporters. - (#119)
cmp.PathStep.Values
provide the currentreflect.Value
for thex
andy
arguments at that given path step.
๐ Bug fixes:
- ๐ (#87) Fixed proper comparing of slices where one is a sub-slice of the other.
Reporter changes:
- โ
(#124) The
cmp.Diff
output has been completely re-written to provide a unified diff of the two Go objects as a literal in pseudo-Go syntax (example). - 0๏ธโฃ (#131) The default reporter has built-in heuristics to detect whether a string or a byte-slice looks like binary data or human readable text, and can provide more humanly readable differences in certain use-cases. For example, a string may be detecting as containing multiple lines of text, for which it will print the difference based on the lines.
- (#108) The
-
v0.2.0 Changes
February 20, 2018โ Added Features:
โ Add implicit filter to transformers where a
Transformer
can only apply if that specific transformer does not already exist within the tail of the currentPath
since the last non-transform step. This filter makes it easier to create same-type transformations (e.g.,func(T) T
) without needing to manually add your own filter. (#29)โ Add
Path.Index
method, which provides an easier way to index aPath
without needing to manually perform bounds checking. (#56)โ Add
Transform.Option
method, which returns the originalTransformer
option. This enables the creation of non-reentrant transformers. (#59)โ Add handling for
purego
build tag, which prevents use ofunsafe
, which is necessary to implementAllowUnexported
. However,unsafe
is not available in some build environments such as GopherJS and Google AppEngine Standard. A future release will remove special casing for these two environments. (#68)Reporting changes:
Diff
only batches multiple differences together for slices of primitives. (#45)- ๐จ
Diff
prints uses as
prefix to indicate that theString
method was used. (#46) - ๐จ
Diff
prints strings using the raw literal syntax when helpful. (#46) Diff
reports the type of a primitive when helpful. (#65)- ๐จ
Path.GoString
elides printing type assertions on anonymous types. (#21)
๐ Bug fixes: