Versions in this module Expand all Collapse all v0 v0.0.1 Jul 23, 2026 Changes in this version + var ErrCanceled = errors.New("comparator: comparison canceled") + var ErrInvalidPatch = errors.New("comparator: invalid JSON patch") + var ErrUnknownFormat = errors.New("comparator: unknown output format") + func ApplyJSONPatch(doc any, patch []JSONPatchOperation) (any, error) + func AssertEqual(t TestingT, want, got any, opts ...Option) bool + func AssertNotEqual(t TestingT, want, got any, opts ...Option) bool + func DeepEqual(a, b any, opts ...Option) bool + func DeepEqualT[T any](a, b T, opts ...Option) bool + func Equal(a, b any, opts ...Option) bool + func EqualCtx(ctx context.Context, a, b any, opts ...Option) (bool, error) + func EqualT[T any](a, b T, opts ...Option) bool + func RegisterFormatter(name string, fn Formatter) bool + func RequireEqual(t TestingT, want, got any, opts ...Option) + func UnregisterFormatter(name string) bool + type Change struct + Content string + Line int + Type string + type Chunk struct + Changes []Change + Context string + type Comparable interface + CompareTo func(other T) int + type Comparator interface + Diff func(a, b any) ([]Difference, error) + Equal func(a, b any) bool + EqualWithConfig func(a, b any, config *Config) bool + func New() Comparator + func NewWithOptions(opts ...Option) Comparator + type Config struct + type ContextComparator interface + CompareWithDiffCtx func(ctx context.Context, a, b any) (*DiffResult, error) + DiffCtx func(ctx context.Context, a, b any) ([]Difference, error) + EqualCtx func(ctx context.Context, a, b any) (bool, error) + type DiffComparer interface + CompareWithDiff func(a, b any) *DiffResult + FormatDiff func(result *DiffResult, format string) (string, error) + GetJSONPatch func(a, b any) ([]JSONPatchOperation, error) + GetUnifiedDiff func(a, b any) (*UnifiedDiff, error) + GetVisualDiff func(a, b any) (*VisualDiff, error) + func NewDiffComparer(opts ...Option) DiffComparer + type DiffMode int + const DiffModeFull + const DiffModeJSONPatch + const DiffModeSimple + const DiffModeUnified + const DiffModeVisual + type DiffResult struct + Differences []Difference + Equal bool + PathStats PathStats + Summary string + func CompareWithDiff(a, b any, opts ...Option) *DiffResult + func CompareWithDiffCtx(ctx context.Context, a, b any, opts ...Option) (*DiffResult, error) + func CompareWithDiffT[T any](a, b T, opts ...Option) *DiffResult + type Difference struct + Detail DifferenceDetail + Level int + Message string + Path string + Severity string + Suggestions []string + func DiffCtx(ctx context.Context, a, b any, opts ...Option) ([]Difference, error) + func DiffT[T any](a, b T, opts ...Option) ([]Difference, error) + type DifferenceDetail struct + ActualType string + ActualValue any + Children []Difference + ExpectedType string + ExpectedValue any + Type string + type Equatable interface + Equals func(other T) bool + type FieldNaming int + const GoFieldNaming + const JSONTagNaming + type Formatter func(result *DiffResult) (string, error) + type JSONPatchOperation struct + From string + Op string + Path string + Value any + func GetJSONPatch(a, b any, opts ...Option) ([]JSONPatchOperation, error) + func GetJSONPatchT[T any](a, b T, opts ...Option) ([]JSONPatchOperation, error) + type Option func(*Config) + func EquateEmpty() Option + func EquateNaNs() Option + func IgnoreSliceOrder() Option + func IgnoreStructFields(fields ...string) Option + func IgnoreUnexported() Option + func WithColorize(enable bool) Option + func WithCustomComparator[T any](comparator func(a, b T) bool) Option + func WithDiffMode(mode DiffMode) Option + func WithEquateEmpty(enable bool) Option + func WithFieldNaming(naming FieldNaming) Option + func WithFloatPrecision(precision float64) Option + func WithIgnoreMapKeys(keys ...string) Option + func WithIgnorePathPatterns(patterns ...string) Option + func WithIgnorePaths(paths ...string) Option + func WithIncludeEqual(enable bool) Option + func WithMaxDepth(depth int) Option + func WithMaxDiffs(max int) Option + func WithOutputFormat(format string) Option + func WithReporter(reporter func(Difference)) Option + func WithTimeLayout(layout string) Option + type PathStats struct + ComparedNodes int + DifferentNodes int + IgnoredNodes int + TotalNodes int + type TestingT interface + Errorf func(format string, args ...any) + Helper func() + type UnifiedDiff struct + Chunks []Chunk + Header string + func (u *UnifiedDiff) String() string + type VisualDiff struct + Root *VisualNode + func (v *VisualDiff) String() string + type VisualNode struct + Children []*VisualNode + Path string + Status string + Value string