base: Index | Files

package embedbin

import ""


Package Files

create.go embedbin.go footer.go


var (
    // ErrNoSuchFile is returned when the embedbin does not contain an
    // embedded file with the requested name.
    ErrNoSuchFile = errors.New("embedded file does not exist")
    // ErrCorruptedImage is returned when the embedbin image has been
    // corrupted.
    ErrCorruptedImage = errors.New("corrupted embedbin image")

func Sniff Uses

func Sniff(r io.ReaderAt, size int64) (offset int64, err error)

Sniff sniffs a binary's embedbin offset. Sniff returns errors returned by the provided reader, or ErrCorruptedImage if the binary is identified as an embedbin image with a checksum mismatch.

type Info Uses

type Info struct {
    Name string
    Size int64

Info provides information for an embedded file.

func (Info) String Uses

func (info Info) String() string

type Reader Uses

type Reader struct {
    // contains filtered or unexported fields

Reader reads images from an embedbin.

func NewReader Uses

func NewReader(r io.ReaderAt, embedOffset, totalSize int64) (*Reader, error)

NewReader returns a new embedbin reader from the provided reader.

func OpenFile Uses

func OpenFile(r io.ReaderAt, size int64) (*Reader, error)

OpenFile parses the provided ReaderAt with the provided size. The file's contents are parsed to determine the offset of the embedbin's archive. OpenFile returns an error if the file is not an embedbin.

func Self Uses

func Self() (*Reader, error)

Self reads the currently executing binary image as an embedbin and returns a reader to it.

func (*Reader) List Uses

func (r *Reader) List() []Info

List returns information about embedded files.

func (*Reader) Open Uses

func (r *Reader) Open(name string) (io.ReadCloser, error)

Open returns a ReadCloser for the named embedded file. Open returns ErrNoSuchImage if the embedbin does not contain the file.

func (*Reader) OpenBase Uses

func (r *Reader) OpenBase() (io.ReadCloser, error)

Open returns a ReadCloser for the original executable, without appended embedded files.

func (*Reader) Stat Uses

func (r *Reader) Stat(name string) (info Info, ok bool)

Stat returns the information for the named embedded file. It returns a boolean indicating whether the requested file was found.

func (*Reader) StatBase Uses

func (r *Reader) StatBase() Info

StatBase returns the information for the base image.

type WriteOpt Uses

type WriteOpt func(*Writer)

WriteOpt is an option to NewWriter.

var Deflate WriteOpt = func(w *Writer) {
    w.embedMethod = zip.Deflate

Deflate compresses embedded files.

type Writer Uses

type Writer struct {
    // contains filtered or unexported fields

Writer is used to append embedbin files to an existing binary.

func NewFileWriter Uses

func NewFileWriter(file *os.File) (*Writer, error)

NewFileWriter returns a writer that can be used to append embedbin files to the binary represented by the provided file. NewFileWriter removes any existing embedbin files that may be attached to the binary. It relies on content sniffing (see Sniff) to determine its offset.

func NewWriter Uses

func NewWriter(w io.Writer, embedOffset int64, opts ...WriteOpt) *Writer

NewWriter returns a writer that may be used to append embedbin files to the writer w. The writer should be positioned at the end of the base binary image.

func (*Writer) Close Uses

func (w *Writer) Close() error

Close should be called after all embedded files have been written. No more files can be written after a call to Close.

func (*Writer) Create Uses

func (w *Writer) Create(name string) (io.Writer, error)

Create returns a Writer into which the named file should be written. The image's contents must be written before the next call to Create or Close.

func (*Writer) Flush Uses

func (w *Writer) Flush() error

Flush flushes the unwritten data to the underlying file.

Package embedbin imports 9 packages (graph). Updated 2020-01-24. Refresh now. Tools for package owners.