// Copyright 2016 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.package gcexportdataimport ()// NewImporter returns a new instance of the types.Importer interface// that reads type information from export data files written by gc.// The Importer also satisfies types.ImporterFrom.//// Export data files are located using "go build" workspace conventions// and the build.Default context.//// Use this importer instead of go/importer.For("gc", ...) to avoid the// version-skew problems described in the documentation of this package,// or to control the FileSet or access the imports map populated during// package loading.//// Deprecated: Use the higher-level API in golang.org/x/tools/go/packages,// which is more efficient.func ( *token.FileSet, map[string]*types.Package) types.ImporterFrom {returnimporter{, }}typeimporterstruct {fset *token.FileSetimportsmap[string]*types.Package}func ( importer) ( string) (*types.Package, error) {return .ImportFrom(, "", 0)}func ( importer) (, string, types.ImportMode) ( *types.Package, error) { , := Find(, )if == "" {if == "unsafe" {// Even for unsafe, call Find first in case // the package was vendored.returntypes.Unsafe, nil }returnnil, fmt.Errorf("can't find import: %s", ) }if , := .imports[]; && .Complete() {return , nil// cache hit }// open file , := os.Open()if != nil {returnnil, }deferfunc() { .Close()if != nil {// add file name to error = fmt.Errorf("reading export data: %s: %v", , ) } }() , := NewReader()if != nil {returnnil, }returnRead(, .fset, .imports, )}
The pages are generated with Goldsv0.4.9. (GOOS=linux GOARCH=amd64)