...

Package archive

import "cmd/internal/archive"
Overview
Index

Overview ▾

Package archive implements reading of archive files generated by the Go toolchain.

Constants

architecture-independent object file output

const HeaderSize = 60

func FormatHeader

func FormatHeader(arhdr []byte, name string, size int64)

func ReadHeader

func ReadHeader(b *bufio.Reader, name string) int

type Archive

type Archive struct {
    Entries []Entry
    // contains filtered or unexported fields
}

func New

func New(f *os.File) (*Archive, error)

New writes to f to make a new archive.

func Parse

func Parse(f *os.File, verbose bool) (*Archive, error)

Parse parses an object file or archive from f.

func (*Archive) AddEntry

func (a *Archive) AddEntry(typ EntryType, name string, mtime int64, uid, gid int, mode os.FileMode, size int64, r io.Reader)

AddEntry adds an entry to the end of a, with the content from r.

func (*Archive) File

func (a *Archive) File() *os.File

type Data

A Data is a reference to data stored in an object file. It records the offset and size of the data, so that a client can read the data only if necessary.

type Data struct {
    Offset int64
    Size   int64
}

type Entry

type Entry struct {
    Name  string
    Type  EntryType
    Mtime int64
    Uid   int
    Gid   int
    Mode  os.FileMode
    Data
    Obj *GoObj // nil if this entry is not a Go object file
}

func (*Entry) String

func (e *Entry) String() string

type EntryType

type EntryType int
const (
    EntryPkgDef EntryType = iota
    EntryGoObj
    EntryNativeObj
    EntrySentinelNonObj
)

type ErrGoObjOtherVersion

type ErrGoObjOtherVersion struct {
    // contains filtered or unexported fields
}

func (ErrGoObjOtherVersion) Error

func (e ErrGoObjOtherVersion) Error() string

type GoObj

type GoObj struct {
    TextHeader []byte
    Arch       string
    Data
}