box

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2020 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package box provides the EmbedBox type and interfaces for storing and interacting with embedded files.

Index

Constants

This section is empty.

Variables

View Source
var EmbedDecoder, _ = zstd.NewReader(nil)

EmbedDecoder is a reader that caches decompressors.

View Source
var Template = newEmbedBox()

Functions

This section is empty.

Types

type CompressedFile

type CompressedFile struct {
	Name              string
	CompressedBytes   []byte
	PreCompressedSize int
}

CompressedFile is the container type for embedded files. The file contents are stored as zstandard compressed byte arrays.

type EmbedBox

type EmbedBox struct {
	Path    string // path, with / being the root directory (directory of `go env gomod`) of the project
	Storage []CompressedFile
}

EmbedBox is the container type for embedded paths. The files within are stored as CompressedFiles.

func (*EmbedBox) Add

func (e *EmbedBox) Add(name string, content []byte)

Add a file to box

func (*EmbedBox) Get

func (e *EmbedBox) Get(file string) ([]byte, error)

Get file's content

func (*EmbedBox) Has

func (e *EmbedBox) Has(file string) bool

Has returns true if the file exists in an EmbedBox, and false otherwise.

func (*EmbedBox) Index

func (e *EmbedBox) Index(file string) (int, error)

Index returns the array index of the named CompressedFile in the EmbedBox.

func (*EmbedBox) ReadEmbeddedFileToString

func (e *EmbedBox) ReadEmbeddedFileToString(path string) (string, error)

ReadEmbeddedFileToString reads the path argument and returns the contents as a string.

func (*EmbedBox) ReadEmbeddedTemplateToString

func (e *EmbedBox) ReadEmbeddedTemplateToString(path string) (string, error)

ReadEmbeddedTemplateToString calls EmbeddedFileToString

Jump to

Keyboard shortcuts

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