exportdata
packagestandard libraryThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package exportdata implements common utilities for findingand reading gc-generated object files.
Index¶
- func FindPackageDefinition(r *bufio.Reader) (size int, err error)
- func FindPkg(path, srcDir string) (filename, id string, err error)
- func ReadExportDataHeader(r *bufio.Reader) (n int, err error)
- func ReadObjectHeaders(r *bufio.Reader) (objapi string, headers []string, err error)
- func ReadUnified(r *bufio.Reader) (data []byte, err error)
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
funcFindPackageDefinition¶
FindPackageDefinition positions the reader r at the beginning of a packagedefinition file ("__.PKGDEF") within a GC-created archive by readingfrom it, and returns the size of the package definition file in the archive.
The reader must be positioned at the start of the archive file before callingthis function, and "__.PKGDEF" is assumed to be the first file in the archive.
See cmd/internal/archive for details on the archive format.
funcFindPkg¶
FindPkg returns the filename and unique package id for an importpath based on package information provided by build.Import (usingthe build.Default build.Context). A relative srcDir is interpretedrelative to the current working directory.
funcReadExportDataHeader¶
ReadExportDataHeader reads the export data header and format from r.It returns the number of bytes read, or an error if the format is no longersupported or it failed to read.
The only currently supported format is binary export data in theunified export format.
funcReadObjectHeaders¶
ReadObjectHeaders reads object headers from the reader. Object headers arelines that do not start with an end-of-section marker "$$". The first headeris the objabi header. On success, the reader will be positioned at the beginningof the end-of-section marker.
It returns an error if any header does not fit in r.Size() bytes.
funcReadUnified¶
ReadUnified reads the contents of the unified export data from a reader rthat contains the contents of a GC-created archive file.
On success, the reader will be positioned after the end-of-section marker "\n$$\n".
Supported GC-created archive files have 4 layers of nesting:
- An archive file containing a package definition file.
- The package definition file contains headers followed by a data section.Headers are lines (≤ 4kb) that do not start with "$$".
- The data section starts with "$$B\n" followed by export data followedby an end of section marker "\n$$\n". (The section start "$$\n" is nolonger supported.)
- The export data starts with a format byte ('u') followed by the <data> inthe given format. (See ReadExportDataHeader for older formats.)
Putting this together, the bytes in a GC-created archive files are expectedto look like the following.See cmd/internal/archive for more details on ar file headers.
| <!arch>\n | ar file signature| __.PKGDEF...size...\n | ar header for __.PKGDEF including size.| go object <...>\n | objabi header| <optional headers>\n | other headers such as build id| $$B\n | binary format marker| u<data>\n | unified export <data>| $$\n | end-of-section marker| [optional padding] | padding byte (0x0A) if size is odd| [ar file header] | other ar files| [ar file data] |
Types¶
This section is empty.