package packr
import "github.com/gobuffalo/packr/v2"
Index ¶
- Constants
- Variables
- func PackBytes(box string, name string, bb []byte)
- func PackBytesGzip(box string, name string, bb []byte) error
- func PackJSONBytes(box string, name string, jbb string) error
- type Box
- func Folder(path string) *Box
- func New(name string, path string) *Box
- func NewBox(path string) *Box
- func (b *Box) AddBytes(path string, t []byte) error
- func (b *Box) AddString(path string, t string) error
- func (b *Box) Bytes(name string) []byte
- func (b *Box) Find(name string) ([]byte, error)
- func (b *Box) FindString(name string) (string, error)
- func (b *Box) Has(name string) bool
- func (b *Box) HasDir(name string) bool
- func (b *Box) List() []string
- func (b *Box) MustBytes(name string) ([]byte, error)
- func (b *Box) MustString(name string) (string, error)
- func (b *Box) Open(name string) (http.File, error)
- func (b *Box) Resolve(key string) (file.File, error)
- func (b *Box) SetResolver(file string, res resolver.Resolver)
- func (b *Box) String(name string) string
- func (b *Box) Walk(wf WalkFunc) error
- func (b *Box) WalkPrefix(prefix string, wf WalkFunc) error
- type File
- type Pointer
- type WalkFunc
Constants ¶
const Version = "v2.8.3"
Version of Packr
Variables ¶
var ( // ErrResOutsideBox gets returned in case of the requested resources being outside the box // Deprecated ErrResOutsideBox = fmt.Errorf("can't find a resource outside the box") )
Functions ¶
func PackBytes ¶
PackBytes packs bytes for a file into a box. Deprecated
func PackBytesGzip ¶
PackBytesGzip packets the gzipped compressed bytes into a box. Deprecated
func PackJSONBytes ¶
PackJSONBytes packs JSON encoded bytes for a file into a box. Deprecated
Types ¶
type Box ¶
type Box struct { Path string `json:"path"` Name string `json:"name"` ResolutionDir string `json:"resolution_dir"` DefaultResolver resolver.Resolver `json:"default_resolver"` // contains filtered or unexported fields }
Box represent a folder on a disk you want to have access to in the built Go binary.
func Folder ¶
Folder returns a Box that will NOT be packed. This is useful for writing tests or tools that need to work with a folder at runtime.
func New ¶
New returns a new Box with the name of the box and the path of the box.
func NewBox ¶
NewBox returns a Box that can be used to retrieve files from either disk or the embedded binary. Deprecated: Use New instead.
func (*Box) AddBytes ¶
AddBytes sets t in b.data by the given path
func (*Box) AddString ¶
AddString converts t to a byteslice and delegates to AddBytes to add to b.data
func (*Box) Bytes ¶
Bytes is deprecated. Use Find instead
func (*Box) Find ¶
Find returns either the byte slice of the requested file or an error if it can not be found.
func (*Box) FindString ¶
FindString returns either the string of the requested file or an error if it can not be found.
func (*Box) Has ¶
Has returns true if the resource exists in the box
func (*Box) HasDir ¶
HasDir returns true if the directory exists in the box
func (*Box) List ¶
List shows "What's in the box?"
func (*Box) MustBytes ¶
MustBytes is deprecated. Use Find instead.
func (*Box) MustString ¶
MustString is deprecated. Use FindString instead
func (*Box) Open ¶
Open returns a File using the http.File interface
func (*Box) Resolve ¶
Resolve will attempt to find the file in the box, returning an error if the find can not be found.
func (*Box) SetResolver ¶
SetResolver allows for the use of a custom resolver for the specified file
func (*Box) String ¶
String is deprecated. Use FindString instead
func (*Box) Walk ¶
Walk will traverse the box and call the WalkFunc for each file in the box/folder.
func (*Box) WalkPrefix ¶
WalkPrefix will call box.Walk and call the WalkFunc when it finds paths that have a matching prefix
type File ¶
File has been deprecated and file.File should be used instead
type Pointer ¶
Pointer is a resolvr which resolves a file from a different box.
func (Pointer) Resolve ¶
Resolve attempts to find the file in the specific box with the specified key
type WalkFunc ¶
WalkFunc is used to walk a box
Source Files ¶
box.go box_map.go deprecated.go dirs_map.go helpers.go packr.go pointer.go resolvers_map.go version.go walk.go
Directories ¶
- Version
- v2.8.3 (latest)
- Published
- Nov 23, 2021
- Platform
- js/wasm
- Imports
- 20 packages
- Last checked
- now –
Tools for package owners.