package importer

import "cmd/compile/internal/importer"

package importer implements Import for gc-generated object files.

Index

Functions

func FindExportData

func FindExportData(r *bufio.Reader) (hdr string, size int, err error)

FindExportData positions the reader r at the beginning of the export data section of an underlying GC-created object/archive file by reading from it. The reader must be positioned at the start of the file before calling this function. The hdr result is the string before the export data, either "$$" or "$$B".

If size is non-negative, it's the number of bytes of export data still available to read from r.

func FindPkg

func FindPkg(path, srcDir string) (filename, id string)

FindPkg returns the filename and unique package id for an import path based on package information provided by build.Import (using the build.Default build.Context). A relative srcDir is interpreted relative to the current working directory. If no file was found, an empty filename is returned.

func Import

func Import(packages map[string]*types2.Package, path, srcDir string, lookup func(path string) (io.ReadCloser, error)) (pkg *types2.Package, err error)

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 ImportData

func ImportData(imports map[string]*types2.Package, data, path string) (pkg *types2.Package, err error)

ImportData imports a package from the serialized package data and returns the number of bytes consumed and a reference to the package. If the export data version is not recognized or the format is otherwise compromised, an error is returned.

func ReadPackage

func ReadPackage(ctxt *types2.Context, imports map[string]*types2.Package, input pkgbits.PkgDecoder) *types2.Package

Source Files

exportdata.go gcimporter.go iimport.go support.go ureader.go

Version
v1.20.13
Published
Jan 4, 2024
Platform
linux/amd64
Imports
22 packages
Last checked
now

Tools for package owners.