// Copyright 2011 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 gcimporter implements Import for gc-generated object files.
package gcimporter // import "go/internal/gcimporter" import ( ) // Import imports a gc-generated package given its import path and srcDir, adds // the corresponding package object to the packages map, and returns the object. // The packages map must contain all packages already imported. func ( *token.FileSet, map[string]*types.Package, , string, func( string) (io.ReadCloser, error)) ( *types.Package, error) { var io.ReadCloser var string if != nil { // With custom lookup specified, assume that caller has // converted path to a canonical import path for use in the map. if == "unsafe" { return types.Unsafe, nil } = // No need to re-import if the package was imported completely before. if = []; != nil && .Complete() { return } , := () if != nil { return nil, } = } else { var string , , = exportdata.FindPkg(, ) if == "" { if == "unsafe" { return types.Unsafe, nil } return nil, } // no need to re-import if the package was imported completely before if = []; != nil && .Complete() { return } // open file , := os.Open() if != nil { return nil, } defer func() { if != nil { // add file name to error = fmt.Errorf("%s: %v", , ) } }() = } defer .Close() := bufio.NewReader() , := exportdata.ReadUnified() if != nil { = fmt.Errorf("import %q: %v", , ) return } := string() := pkgbits.NewPkgDecoder(, ) = readUnifiedPackage(, nil, , ) return }