Documentation
¶
Overview ¶
Package registry is the kind-to-instance table that NewSentinel writes and errors/wire reads, so a decoded leaf can become the registered instance again (spec 0003 D5). It is internal because only those two may write to it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func KindOf ¶
KindOf returns the kind err was registered under, with ok true only when err is that kind's one instance. The first two instances of an ambiguous kind get the kind with ok false, and a third or later, which is not recorded, gets "".
func Register ¶
Register records err under kind. An empty kind is ignored. A kind under a reserved prefix, an uncomparable instance, and an instance already registered under another kind are refused and reported by Conflicts.
func RegisterBuiltin ¶
RegisterBuiltin records err under kind with no prefix check. Only errors/wire calls it, for the standard-library leaves under std.
func RegisterNew ¶
RegisterNew records err under kind, as Register does, for an instance the caller has just created. It skips the identity scan, so registering N sentinels is linear rather than quadratic.
Types ¶
type Reason ¶
type Reason int
Reason says why a kind will not decode to its registered instance.
const ( // Ambiguous means two different instances were registered under the kind, // or the instance was already registered under another kind. Ambiguous Reason = iota + 1 // Reserved means the kind is under a prefix only the core may use. Reserved // Uncomparable means the instance's type cannot be compared with ==, so a // leaf can never be recognised as it. Uncomparable )