Movatterモバイル変換


[0]ホーム

URL:


exportdata

packagestandard library
go1.25.2Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2025 License:BSD-3-ClauseImports:13Imported by:0

Details

Repository

cs.opensource.google/go/go

Links

Documentation

Overview

Package exportdata implements common utilities for findingand reading gc-generated object files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

funcFindPackageDefinition

func FindPackageDefinition(r *bufio.Reader) (sizeint, errerror)

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

func FindPkg(path, srcDirstring) (filename, idstring, errerror)

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

func ReadExportDataHeader(r *bufio.Reader) (nint, errerror)

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

func ReadObjectHeaders(r *bufio.Reader) (objapistring, headers []string, errerror)

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

func ReadUnified(r *bufio.Reader) (data []byte, errerror)

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.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp