Documentation
¶
Overview ¶
Package jsondiff makes "100% compatible with GitHub" mechanical. It compares a Githome response against a recorded GitHub response (the golden), enforcing structure, types, and nullability while ignoring values that legitimately vary between instances (ids, timestamps, hosts, rate-limit counters).
The asymmetry is deliberate: every key GitHub sends must be present with the same type and nullability, and Githome must not send keys GitHub does not. Values are compared only where they carry contract meaning (a resource label, a URL path), never where they are instance-specific.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Diff ¶
Diff is one structural or value difference found by Compare.
type Kind ¶
type Kind int
Kind classifies a single difference.
const ( MissingKey Kind = iota // present in want, absent in got ExtraKey // present in got, absent in want TypeMismatch // different JSON types Nullability // one is null, the other is not ValueMismatch // values that must match do not LengthMismatch // arrays of different length )
The kinds of difference Compare can report.
type Options ¶
type Options struct {
// Hosts are rewritten to the sentinel "HOST" before comparing URL strings, so
// a Githome link compares equal to the captured github.com link by path.
Hosts []string
// IgnoreValueKeys names keys whose value varies between instances; presence
// and type are still enforced, only the value is skipped.
IgnoreValueKeys map[string]bool
}
Options controls normalization during comparison.