gar

package module
v0.0.0-...-0ca4cbb Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2014 License: GPL-3.0 Imports: 12 Imported by: 0

README

gar - Go application archiver

gar is an application archiver for Go inspired by JAR for Java. All external resources required for running an application, such as templates and public assets for a web application. are archived directly with the binary to create a completely portable application.

Comparison with go.rice

go.rice is another Go archiver solving the same problems gar aims to solve, however there are some design differences between the two.

  • go.rice uses zip for both archiving and compression, whereas gar uses tar archiving with optional gzip compression so the packager can choose to optimise either for loading performance or package size.
  • go.rice relies on an external tool for archiving and compressing and currently does not work under Windows. gar uses Go's core tar and gzip packages which makes it portable to all systems supported by Go.
  • go.rice loads all resources into memory which can be problematic for applications with large resources. gar supports loading into memory by default, but can configured to load to the file system instead to save memory.
  • go.rice supports source generation which provides another packaging option, gar only supports appending an archive to the binary.

Documentation

Index

Constants

View Source
const (
	FlagGzip = 1 << iota
	FlagExtractFileSystem
)
View Source
const (
	GarIdentifier      = "GAR"
	GarFileSizeOptSize = 8
	GarFlagsSize       = 1
	GarOptsSize        = GarFileSizeOptSize + GarFlagsSize
	GarFooterSize      = len(GarIdentifier) + GarOptsSize
)

Variables

View Source
var FilesNoHiddenOrGo = regexp.MustCompile("")

Functions

func Files

func Files() (files []string, err error)

func SetGlobalLoader

func SetGlobalLoader(loader *Loader)

Types

type ByteReaderCloser

type ByteReaderCloser struct {
	*bytes.Reader
}

func NewByteReaderCloser

func NewByteReaderCloser(b []byte) *ByteReaderCloser

func (*ByteReaderCloser) Close

func (brc *ByteReaderCloser) Close() error

type File

type File struct {
	FileInfo os.FileInfo
	Content  ReadSeekCloser
}

func Open

func Open(name string) (file File, ok bool, err error)

type FileSystem

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

func NewFileSystemSource

func NewFileSystemSource(base string) FileSystem

func (FileSystem) Files

func (fs FileSystem) Files() ([]string, error)

func (FileSystem) Open

func (fs FileSystem) Open(name string) (file File, ok bool, err error)

type GarInfo

type GarInfo struct {
	Flags byte
	Size  int64
}

func Stat

func Stat(r io.ReadSeeker) (is bool, info GarInfo, err error)

func (GarInfo) IsFlag

func (g GarInfo) IsFlag(flag byte) bool

func (*GarInfo) SetFlag

func (g *GarInfo) SetFlag(flag byte, value bool)

func (GarInfo) WriteTo

func (gi GarInfo) WriteTo(w io.Writer) error

type Loader

type Loader struct {
	Sources []Source
}

func DefaultLoader

func DefaultLoader() (*Loader, error)

func GlobalLoader

func GlobalLoader() (*Loader, error)

func NewLoader

func NewLoader(sources ...Source) *Loader

func (*Loader) AddSource

func (l *Loader) AddSource(source Source)

func (*Loader) Files

func (l *Loader) Files() ([]string, error)

func (*Loader) Open

func (l *Loader) Open(name string) (file File, ok bool, err error)

type ReadSeekCloser

type ReadSeekCloser interface {
	io.Reader
	io.Seeker
	io.Closer
}

type Reader

type Reader struct {
	GarInfo GarInfo
	// contains filtered or unexported fields
}

func NewReader

func NewReader(r io.ReadSeeker) (*Reader, error)

func (*Reader) Read

func (r *Reader) Read(p []byte) (n int, err error)

type Source

type Source interface {
	Open(name string) (file File, ok bool, err error)
	Files() ([]string, error)
}

type Tar

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

func NewGarSource

func NewGarSource(r io.ReadSeeker) (tar *Tar, err error)

func NewTarSource

func NewTarSource(r io.Reader) *Tar

func (*Tar) Extract

func (t *Tar) Extract(dir string) error

func (*Tar) Files

func (t *Tar) Files() ([]string, error)

func (*Tar) Load

func (t *Tar) Load() error

func (*Tar) LoadIfRequired

func (t *Tar) LoadIfRequired() error

func (*Tar) Open

func (t *Tar) Open(name string) (file File, ok bool, err error)

type Writer

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

func NewWriter

func NewWriter(w io.Writer) *Writer

func (*Writer) Close

func (w *Writer) Close(flags byte) error

func (*Writer) WriteFile

func (w *Writer) WriteFile(hdr *tar.Header, contents io.Reader) error

func (*Writer) WriteFileAtPath

func (w *Writer) WriteFileAtPath(source, target string) error

func (*Writer) WriteFileWithFileInfo

func (w *Writer) WriteFileWithFileInfo(name string, fi os.FileInfo, contents io.Reader) error

func (*Writer) WriteFileWithName

func (w *Writer) WriteFileWithName(name string, contents io.Reader) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL