type Index … // Decode decodes the given gob-encoded data as an Index. func Decode(data []byte) *Index { … } // Encode encodes the receiver as gob-encoded data. func (index *Index) Encode() []byte { … } // NewIndex returns a new index of method-set information for all // package-level types in the specified package. func NewIndex(fset *token.FileSet, pkg *types.Package) *Index { … } type Location … type Key … // KeyOf returns the search key for the method sets of a given type. // It returns false if the type has no methods. func KeyOf(t types.Type) (Key, bool) { … } type Result … // Search reports each type that implements (or is implemented by) the // type that produced the search key. If methodID is nonempty, only // that method of each type is reported. // // The result does not include the error.Error method. // TODO(adonovan): give this special case a more systematic treatment. func (index *Index) Search(key Key, methodID string) []Result { … } // satisfies does a fast check for whether x satisfies y. func satisfies(x, y gobMethodSet) bool { … } // subset reports whether method set x is a subset of y. func subset(x, y gobMethodSet) bool { … } func (index *Index) location(posn gobPosition) Location { … } type indexBuilder … // build adds to the index all package-level named types of the specified package. func (b *indexBuilder) build(fset *token.FileSet, pkg *types.Package) *Index { … } // string returns a small integer that encodes the string. func (b *indexBuilder) string(s string) int { … } // methodSetInfo returns the method-set fingerprint of a type. // It calls the optional setIndexInfo function for each gobMethod. // This is used during index construction, but not search (KeyOf), // to store extra information. func methodSetInfo(t types.Type, setIndexInfo func(*gobMethod, *types.Func)) gobMethodSet { … } // EnsurePointer wraps T in a types.Pointer if T is a named, non-interface type. // This is useful to make sure you consider a named type's full method set. func EnsurePointer(T types.Type) types.Type { … } // fingerprint returns an encoding of a method signature such that two // methods with equal encodings have identical types, except for a few // tricky types whose encodings may spuriously match and whose exact // identity computation requires the type checker to eliminate false // positives (which are rare). The boolean result indicates whether // the result was one of these tricky types. // // 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. // // The fingerprint string starts with method.Id() + "(". func fingerprint(method *types.Func) (string, bool) { … } var packageCodec … type gobPackage … type gobMethodSet … type gobMethod … type gobPosition …