embedder

package module
v0.0.0-...-5942e05 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2021 License: NCSA Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoCompression compressionAlgo = iota
	GzipCompression
	ZlibCompression
	LZMACompression
	LZ4Compression
	ZipArchive
)

Variables

View Source
var BucketLoader func(string) *Bucket
View Source
var ErrIncompleteWrite = errors.NewError("incomplete write")
View Source
var ErrInvalidImplementation = fmt.Errorf("invalid ReadSeekCloser implementation")
View Source
var ErrNoBucketLoader = errors.NewError("no bucket loader")
View Source
var ErrNoSuchBucket = errors.NewError("no such bucket")
View Source
var ErrNoSuchFile = fmt.Errorf("no such file")
View Source
var Templates_ca609873c33c8dd143c014400a89a185a60c00a91728607693d79c5fad608e6a = &Asset{
	Name:            "asset-src.go.tpl",
	Path:            "templates/asset-src.go.tpl",
	OverridePath:    "",
	IsArchive:       false,
	CompressionAlgo: GzipCompression,
	Encoding:        0,
	Size:            1583,
	Content: []byte{
		0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
		0xff, 0x7c, 0x54, 0x4d, 0x6f, 0x1a, 0x31, 0x10,
		0x3d, 0xdb, 0xbf, 0x62, 0x8a, 0x50, 0x04, 0x29,
		0xd9, 0xdc, 0x91, 0xf6, 0x40, 0xd2, 0x48, 0x8d,
		0xd4, 0xa6, 0x91, 0xd2, 0x9c, 0xaa, 0xaa, 0x5a,
		0x76, 0x07, 0x62, 0x05, 0xbc, 0xc8, 0xf6, 0x92,
		0x50, 0x6b, 0xfe, 0x7b, 0x35, 0xfe, 0x58, 0xa0,
		0x82, 0xdc, 0xbc, 0xf3, 0x66, 0x3c, 0xcf, 0x33,
		0xef, 0xad, 0xf7, 0xa0, 0x16, 0x50, 0xdc, 0x74,
		0x6a, 0xd5, 0xfc, 0xac, 0x96, 0x16, 0x88, 0xae,
		0xaf, 0xe1, 0xf3, 0x9c, 0xbf, 0x21, 0x81, 0x5f,
		0x70, 0xfb, 0xbd, 0x6d, 0x10, 0x88, 0x3e, 0x35,
		0xb8, 0xf5, 0x1e, 0x50, 0x37, 0x40, 0x94, 0xd0,
		0xbb, 0x77, 0x67, 0xaa, 0x54, 0x3a, 0xf1, 0x1e,
		0x8e, 0x02, 0x7d, 0xb2, 0xdc, 0x9f, 0x36, 0x55,
		0xfd, 0x5a, 0x2d, 0x91, 0x6f, 0x2f, 0x1e, 0xe3,
		0xf9, 0xa1, 0x5a, 0xf3, 0xf5, 0x92, 0xb3, 0x86,
		0xb8, 0x9e, 0x63, 0xd3, 0xa0, 0x81, 0x69, 0x09,
		0xc5, 0x5d, 0xfa, 0x78, 0x34, 0xb8, 0x50, 0xef,
		0x40, 0xe1, 0x22, 0xb5, 0x00, 0xdd, 0x3a, 0x28,
		0x1e, 0xda, 0x0c, 0xdf, 0xaf, 0x37, 0xad, 0x71,
		0x0c, 0xab, 0x78, 0x1a, 0x49, 0x31, 0x08, 0x64,
		0x52, 0x7d, 0x4c, 0x78, 0xac, 0xdc, 0x0b, 0x10,
		0x0d, 0xe4, 0x98, 0x3b, 0xe1, 0xca, 0x86, 0xae,
		0xde, 0x1f, 0x34, 0x2d, 0x61, 0x30, 0xe0, 0x7b,
		0xf6, 0x7c, 0xa5, 0xdb, 0x6d, 0x10, 0x6e, 0xba,
		0xfa, 0x15, 0x9d, 0x05, 0xeb, 0x4c, 0x57, 0x3b,
		0xf0, 0xd2, 0x7b, 0x53, 0xe9, 0x25, 0xc2, 0x70,
		0xae, 0x26, 0x30, 0x9c, 0x77, 0x0c, 0x07, 0xca,
		0x29, 0x93, 0x48, 0x0a, 0xef, 0x87, 0x11, 0x28,
		0x9e, 0x6f, 0xf9, 0x8d, 0x44, 0x70, 0x79, 0xd4,
		0x8d, 0x28, 0x66, 0x4b, 0xef, 0x51, 0x37, 0x44,
		0x92, 0xe4, 0xb6, 0x32, 0x10, 0x8b, 0x2c, 0x5c,
		0x46, 0xd4, 0x86, 0xc1, 0x7c, 0xdc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x47, 0x16, 0x21, 0xbb, 0xf3, 0xd9, 0xe2,
		0xbd, 0x56, 0x41, 0xde, 0x8b, 0x4e, 0xd7, 0xa0,
		0xb4, 0x72, 0xa3, 0x31, 0x78, 0x29, 0xf2, 0x23,
		0x93, 0xe8, 0xbe, 0xb5, 0x15, 0x1b, 0xa7, 0x04,
		0x3e, 0x44, 0xed, 0xc8, 0xe0, 0x98, 0x7c, 0x61,
		0x28, 0xdf, 0x83, 0x23, 0xcd, 0xc6, 0xb3, 0x81,
		0xde, 0xf8, 0x8c, 0x34, 0xb9, 0x8d, 0x5a, 0x40,
		0x14, 0x8b, 0x85, 0xb2, 0x04, 0xad, 0x56, 0x1c,
		0x14, 0x7d, 0x08, 0x2e, 0x62, 0x2f, 0xeb, 0x83,
		0xe6, 0x7b, 0x05, 0x9e, 0x71, 0x06, 0xdb, 0xab,
		0xaf, 0x2e, 0x78, 0x39, 0xf1, 0xa6, 0xbd, 0x12,
		0xa1, 0x0c, 0xcb, 0xce, 0xaf, 0x03, 0xa2, 0x07,
		0x7c, 0x8b, 0x3d, 0x46, 0x52, 0x88, 0x60, 0xed,
		0x5c, 0xc4, 0x22, 0x4c, 0x5a, 0x39, 0x06, 0x58,
		0x5d, 0x67, 0x81, 0xfe, 0x7f, 0x32, 0x18, 0x4b,
		0x21, 0x78, 0xe6, 0xc9, 0x5e, 0x67, 0x5d, 0x23,
		0xf2, 0x7b, 0x4f, 0x32, 0x2e, 0x66, 0x4d, 0x13,
		0x6c, 0x31, 0x3a, 0xf5, 0x9e, 0xd3, 0xce, 0xca,
		0x9d, 0x79, 0x39, 0xec, 0xde, 0x40, 0x83, 0x3f,
		0xf8, 0xd7, 0x41, 0x52, 0x0a, 0xfb, 0xa6, 0x5c,
		0xfd, 0x02, 0x61, 0x49, 0x9e, 0xe1, 0x4c, 0xf2,
		0xa3, 0xc1, 0xd6, 0x95, 0xc5, 0xe8, 0xc9, 0x34,
		0xd5, 0x3c, 0xa0, 0xa9, 0x14, 0xc2, 0xa0, 0xeb,
		0x8c, 0xce, 0xcb, 0x3c, 0xf9, 0x92, 0xd0, 0xe7,
		0x90, 0x85, 0x41, 0xd7, 0x19, 0x0d, 0x5a, 0xad,
		0x24, 0xfd, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x70,
		0x69, 0x5b, 0x7d, 0x2f, 0x06, 0x00, 0x00,
	},
}

Functions

func Embed

func Embed(options *EmbedderOptions, paths ...string)

func ReadBuffer

func ReadBuffer(buf []byte, algo compressionAlgo) ([]byte, error)

Types

type Asset

type Asset struct {
	// Name of this asset. This is a symbolic name that is used by API consumers
	// to locate the asset.
	Name string

	// Path to asset folder.
	Path string

	// OverridePath for externally superceding embedded asset contents (e.g.
	// push patches).
	OverridePath string

	// Size of the asset contents.
	Size int64

	// Ctime indicates the creation time of the asset bundle. This is a constant
	// value across all assets in a single bucket (and may be moved to the
	// bucket meta).
	Ctime time.Time

	// Mtime indicates the modification time of the asset. This reflects the
	// modification time, on disk, when the asset bundle was created.
	Mtime time.Time

	// IsArchive indicates that the embedded asset is (or should be) an archive.
	// If this flag is true and Path points to a directory, the asset will be
	// compressed into a .zip file and added to the binary.
	//
	// When reading, this will utilize nested VFS support to extract the zipped
	// assets as would otherwise be accessed if they were embedded as is.
	IsArchive bool

	// CompressionAlgo indicates the compression algorithm used for this asset.
	CompressionAlgo compressionAlgo

	// Encoding type. One of EncodeAsBytes or EncodeAsBase64.
	Encoding Encoding

	// Content for this asset.
	Content []byte

	// ContentReader is used if Content is null and ContentReader is not null.
	ContentReader io.Reader
}

func (*Asset) ByteString

func (a *Asset) ByteString() (buf []string)

TODO: Replace with byte string proxy that returns an io.Reader.

func (*Asset) NameHash

func (a *Asset) NameHash() string

type AssetReader

type AssetReader interface {
	// Name returns the symbolic name associated with this asset.
	Name() string
}

type Bucket

type Bucket struct {
	// Name of this bucket.
	Name string

	// Path of the bucket on disk. May be relative or absolute.
	Path string

	// PathPrefix to remove when saving assets. This is useful for absolute paths
	PathPrefix string

	// Assets map. If this isn't populated, Embed() will populate it.
	Assets map[string]*Asset
	// contains filtered or unexported fields
}

func LoadBucket

func LoadBucket(name string) *Bucket

func NewBucket

func NewBucket(name, path, prefix string) *Bucket

func (*Bucket) AddAsset

func (b *Bucket) AddAsset(asset *Asset)

func (*Bucket) LCName

func (b *Bucket) LCName() string

func (*Bucket) Read

func (b *Bucket) Read(path string) (vfs.ReadOnlyFile, error)

func (*Bucket) UCName

func (b *Bucket) UCName() string

UCName returns the bucket name with its first character uppercased.

type Buckets

type Buckets struct {
	Templates *Bucket
}

type EmbedderFileInfo

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

func (*EmbedderFileInfo) IsDir

func (fi *EmbedderFileInfo) IsDir() bool

func (*EmbedderFileInfo) ModTime

func (fi *EmbedderFileInfo) ModTime() time.Time

func (*EmbedderFileInfo) Mode

func (fi *EmbedderFileInfo) Mode() os.FileMode

func (*EmbedderFileInfo) Name

func (fi *EmbedderFileInfo) Name() string

func (*EmbedderFileInfo) Size

func (fi *EmbedderFileInfo) Size() int64

func (*EmbedderFileInfo) Sys

func (fi *EmbedderFileInfo) Sys() interface{}

type EmbedderOptions

type EmbedderOptions struct {
	DevMode          bool
	ExtraTags        string
	TemplateFile     string
	NoEmbedderImport bool
	OutputFile       string
	Overwrite        bool
	UseInit          bool
	PackageName      string
}

type EmbedderVFS

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

func NewEmbedderVFS

func NewEmbedderVFS(bucket *Bucket) *EmbedderVFS

func VFS

func VFS(name string, loader ...func(string) *Bucket) (*EmbedderVFS, error)

func VFSOptions

func VFSOptions(name, basedir string, loader func(string) *Bucket) (*EmbedderVFS, error)

func (*EmbedderVFS) Abs

func (v *EmbedderVFS) Abs(path string) (string, error)

func (*EmbedderVFS) Chdir

func (v *EmbedderVFS) Chdir(path string) error

func (*EmbedderVFS) Chroot

func (v *EmbedderVFS) Chroot(root string) (vfs.VFS, error)

func (*EmbedderVFS) Clone

func (v *EmbedderVFS) Clone() vfs.VFS

func (*EmbedderVFS) Cwd

func (v *EmbedderVFS) Cwd() string

func (*EmbedderVFS) Glob

func (v *EmbedderVFS) Glob(pattern string) ([]string, error)

func (*EmbedderVFS) IsEmpty

func (v *EmbedderVFS) IsEmpty() bool

func (*EmbedderVFS) Lstat

func (v *EmbedderVFS) Lstat(path string) (vfs.FileInfo, error)

Lstat returns the associated vfs.FileInfo for path.

func (*EmbedderVFS) MaskedAbs

func (v *EmbedderVFS) MaskedAbs(path string) (string, error)

func (*EmbedderVFS) Mutable

func (v *EmbedderVFS) Mutable() vfs.MutableFS

func (*EmbedderVFS) Open

func (v *EmbedderVFS) Open(path string) (vfs.ReadOnlyFile, error)

func (*EmbedderVFS) ReadDir

func (v *EmbedderVFS) ReadDir(path string) (entries []vfs.DirEntry, err error)

func (*EmbedderVFS) ReadOnly

func (v *EmbedderVFS) ReadOnly() bool

ReadOnly always returns true for the EmbedderVFS type.

func (*EmbedderVFS) SetReadOnly

func (v *EmbedderVFS) SetReadOnly(ro bool)

SetReadOnly state. This is a noop for EmbedderVFS.

func (*EmbedderVFS) SetRoot

func (v *EmbedderVFS) SetRoot(root string) error

func (*EmbedderVFS) Stat

func (v *EmbedderVFS) Stat(path string) (vfs.FileInfo, error)

Stat returns the associated vfs.FileInfo for path.

This is presently a pass-through for Lstat as both functions return the same values as Embedder does not currently support links.

func (*EmbedderVFS) String

func (v *EmbedderVFS) String() string

type Encoding

type Encoding int
const (
	// EncodoAsBytes writes the assets as a Go byte slice.
	EncodeAsBytes Encoding = iota + 1

	// EncodeAsBase64 writes the assets as a base64-encoded string.
	EncodeAsBase64
)

type MLCRSTree

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

func NewMLCRSTree

func NewMLCRSTree() *MLCRSTree

func NewMLCRSTreeFromMap

func NewMLCRSTreeFromMap(m map[string]*Asset) *MLCRSTree

func (*MLCRSTree) Insert

func (m *MLCRSTree) Insert(p string, asset *Asset)

func (*MLCRSTree) ListPath

func (m *MLCRSTree) ListPath(path string) (nodes []*node)

func (*MLCRSTree) LoadAsset

func (m *MLCRSTree) LoadAsset(path string) *Asset

func (*MLCRSTree) Paths

func (m *MLCRSTree) Paths() []string

func (*MLCRSTree) ReadPath

func (m *MLCRSTree) ReadPath(path string) (n *node)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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