Back to godoc.org
github.com/gobuffalo/packr

package packr

v1.30.1
Latest Go to latest
Published: Jun 24, 2019 | License: MIT | Module: github.com/gobuffalo/packr

Index

Constants

const Version = "v1.30.1"

Variables

var (
	// ErrResOutsideBox gets returned in case of the requested resources being outside the box
	ErrResOutsideBox = fmt.Errorf("Can't find a resource outside the box")
)
var GoBin = envy.GoBin

GoBin returns the current GO_BIN env var or if it's missing, a default of "go"

var GoPath = envy.GoPath

GoPath returns the current GOPATH env var or if it's missing, the default.

func PackBytes

func PackBytes(box string, name string, bb []byte)

PackBytes packs bytes for a file into a box.

func PackBytesGzip

func PackBytesGzip(box string, name string, bb []byte) error

PackBytesGzip packets the gzipped compressed bytes into a box.

func PackJSONBytes

func PackJSONBytes(box string, name string, jbb string) error

PackJSONBytes packs JSON encoded bytes for a file into a box.

func UnpackBytes

func UnpackBytes(box string)

UnpackBytes unpacks bytes for specific box.

type Box

type Box struct {
	Path string
	// contains filtered or unexported fields
}

Box represent a folder on a disk you want to have access to in the built Go binary.

func NewBox

func NewBox(path string) Box

NewBox returns a Box that can be used to retrieve files from either disk or the embedded binary.

func (Box) AddBytes

func (b Box) AddBytes(path string, t []byte) error

AddBytes sets t in b.data by the given path

func (Box) AddString

func (b Box) AddString(path string, t string) error

AddString converts t to a byteslice and delegates to AddBytes to add to b.data

func (Box) Bytes

func (b Box) Bytes(name string) []byte

Deprecated: Use Find instead.

func (Box) Find

func (b Box) Find(name string) ([]byte, error)

Find returns either the byte slice of the requested file or an error if it can not be found.

func (Box) FindString

func (b Box) FindString(name string) (string, error)

FindString returns either the string of the requested file or an error if it can not be found.

func (Box) Has

func (b Box) Has(name string) bool

Has returns true if the resource exists in the box

func (Box) List

func (b Box) List() []string

List shows "What's in the box?"

func (Box) MustBytes

func (b Box) MustBytes(name string) ([]byte, error)

Deprecated: Use Find instead.

func (Box) MustString

func (b Box) MustString(name string) (string, error)

Deprecated: Use FindString instead.

func (Box) Open

func (b Box) Open(name string) (http.File, error)

Open returns a File using the http.File interface

func (Box) String

func (b Box) String(name string) string

Deprecated: Use FindString instead.

func (Box) Walk

func (b Box) Walk(wf WalkFunc) error

Walk will traverse the box and call the WalkFunc for each file in the box/folder.

func (Box) WalkPrefix

func (b Box) WalkPrefix(prefix string, wf WalkFunc) error

WalkPrefix will call box.Walk and call the WalkFunc when it finds paths that have a matching prefix

type File

type File = packd.File

type WalkFunc

type WalkFunc = packd.WalkFunc
Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier