Documentation
¶
Overview ¶
Package fingerprint defines a function to Encode types as strings with the property that identical types have equal string encodings, in most cases. In the remaining cases (mostly involving generic types), the encodings can be parsed using Parse into Tree form and matched using Matches.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Encode ¶
Encode returns an encoding of a types.Type such that, in most cases, Encode(x) == Encode(y) iff types.Identical(x, y).
For a minority of types, mostly involving type parameters, identity cannot be reduced to string comparison; these types are called "tricky", and are indicated by the boolean result.
In general, computing identity correctly for tricky types requires the type checker. However, the fingerprint encoding can be parsed by Parse into a Tree form that permits simple matching sufficient to allow a type parameter to unify with any subtree; see [Match].
In the standard library, 99.8% of package-level types have a non-tricky method-set. The most common exceptions are due to type parameters.
fingerprint.Encode is defined only for the signature types of functions and methods. It must not be called for "untyped" basic types, nor the type of a generic function.