slate

package
v1.0.4-0...-5f660c9 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package slate holds binary resources embedded into Go executable

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyTo

func CopyTo(target string, mode os.FileMode, overwrite bool, files ...string) error

The CopyTo method extracts all mentioned files to a specified location, keeping directory structure. If supplied file is a directory, than it will be extracted recursively. CopyTo with no file mentioned will extract the whole content of the embedded filesystem. CopyTo returns error if there is a file with the same name at the target location, unless overwrite is set to true, or file has the same size and modification file as the extracted file. slate.CopyTo(".", mode, false) will effectively extract content of the filesystem to the current directory (which makes it the most space-wise inefficient self-extracting archive ever).

Types

type Asset

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

Asset represents binary resource stored within Go executable. Asset implements fmt.Stringer and io.WriterTo interfaces, decompressing binary data if necessary.

func Get

func Get(name string) *Asset

Gets asset by name. Returns nil if no asset found.

func Must

func Must(name string) *Asset

Get asset by name. Panics if no asset found.

func (*Asset) Bytes

func (a *Asset) Bytes() []byte

Bytes returns (uncompressed) content of asset as a []byte

func (*Asset) IsCompressed

func (a *Asset) IsCompressed() bool

IsCompressed returns true of asset has been compressed

func (*Asset) IsDir

func (a *Asset) IsDir() bool

IsDir implements os.FileInfo and returns false

func (*Asset) MimeType

func (a *Asset) MimeType() string

MimeType returns MIME Type of the asset

func (*Asset) ModTime

func (a *Asset) ModTime() time.Time

ModTime implements os.FileInfo and returns the time stamp when this package has been produced (the same value for all the assets)

func (*Asset) Mode

func (a *Asset) Mode() os.FileMode

Mode implements os.FileInfo and always returns 0444

func (*Asset) Name

func (a *Asset) Name() string

Name returns the base name of the asset

func (*Asset) Reader

func (a *Asset) Reader() io.ReadCloser

Returns content of the asset as io.ReaderCloser.

func (*Asset) Size

func (a *Asset) Size() int64

Size implements os.FileInfo and returns the size of the asset (uncompressed, if asset has been compressed)

func (*Asset) String

func (a *Asset) String() string

String returns (uncompressed, if necessary) content of asset as a string

func (*Asset) Sys

func (a *Asset) Sys() interface{}

Sys implements os.FileInfo and returns nil

func (*Asset) WriteTo

func (a *Asset) WriteTo(w io.Writer) (int64, error)

WriteTo implements io.WriterTo interface and writes content of the asset to w

type File

type File interface {
	io.Closer
	io.Reader
	io.Seeker
	Readdir(count int) ([]os.FileInfo, error)
	Stat() (os.FileInfo, error)
}

A File is returned by virtual FileSystem's Open method. The methods should behave the same as those on an *os.File.

func Open

func Open(name string) (File, error)

Opens asset as an io.ReadCloser. Returns os.ErrNotExist if no asset is found.

type FileSystem

type FileSystem interface {
	Open(name string) (File, error)
	Stat(name string) (os.FileInfo, error)
	// As in filepath.Walk
	Walk(root string, walkFunc filepath.WalkFunc) error
}

A simple FileSystem abstraction

func FS

func FS() FileSystem

Returns embedded FileSystem

func NewUnionFS

func NewUnionFS(src string) (FileSystem, error)

Jump to

Keyboard shortcuts

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