packd

package module
Version: v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2021 License: MIT Imports: 11 Imported by: 131

README

GoDoc Build Status Go Report Card

github.com/gobuffalo/packd

This is a collection of interfaces designed to make using github.com/gobuffalo/packr easier, and to make the transition between v1 and v2 as seamless as possible.

They can, and should, be used for testing, alternate Box implementations, etc...

Installation

$ go get -u -v github.com/gobuffalo/packd

Memory Box

The packd#MemoryBox is a complete, thread-safe, implementation of packd#Box

Documentation

Index

Constants

View Source
const Version = "v0.3.0"

Version of packd

Variables

View Source
var CommonSkipPrefixes = []string{".", "_", "node_modules", "vendor"}

Functions

func SkipWalker

func SkipWalker(walker Walker, skipPrefixes []string, wf WalkFunc) error

SkipWalker will walk the Walker and call the WalkFunc for files who's directories do no match any of the skipPrefixes. If no skipPrefixes are passed, then CommonSkipPrefixes is used

Types

type Addable

type Addable interface {
	AddString(path string, t string) error
	AddBytes(path string, t []byte) error
}

type Box

type Box interface {
	HTTPBox
	Lister
	Addable
	Finder
	Walkable
	Haser
}

Box represents the entirety of the necessary interfaces to form a "full" box. github.com/gobuffalo/packr#Box is an example of this interface.

type ByteMap added in v0.2.0

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

ByteMap wraps sync.Map and uses the following types: key: string value: []byte

func (*ByteMap) Delete added in v0.2.0

func (m *ByteMap) Delete(key string)

Delete the key from the map

func (*ByteMap) Keys added in v0.2.0

func (m *ByteMap) Keys() []string

Keys returns a list of keys in the map

func (*ByteMap) Load added in v0.2.0

func (m *ByteMap) Load(key string) ([]byte, bool)

Load the key from the map. Returns []byte or bool. A false return indicates either the key was not found or the value is not of type []byte

func (*ByteMap) LoadOrStore added in v0.2.0

func (m *ByteMap) LoadOrStore(key string, value []byte) ([]byte, bool)

LoadOrStore will return an existing key or store the value if not already in the map

func (*ByteMap) Range added in v0.2.0

func (m *ByteMap) Range(f func(key string, value []byte) bool)

Range over the []byte values in the map

func (*ByteMap) Store added in v0.2.0

func (m *ByteMap) Store(key string, value []byte)

Store a []byte in the map

type File

type File interface {
	HTTPFile
	FileInfo() (os.FileInfo, error)
}

func NewDir

func NewDir(name string) (File, error)

NewDir returns a new "virtual" directory

func NewFile

func NewFile(name string, r io.Reader) (File, error)

NewFile returns a new "virtual" file

type Finder

type Finder interface {
	Find(string) ([]byte, error)
	FindString(name string) (string, error)
}

type HTTPBox

type HTTPBox interface {
	Open(name string) (http.File, error)
}

type HTTPFile

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

type Haser

type Haser interface {
	Has(string) bool
}

type LegacyBox

type LegacyBox interface {
	String(name string) string
	MustString(name string) (string, error)
	Bytes(name string) []byte
	MustBytes(name string) ([]byte, error)
}

LegacyBox represents deprecated methods that older Box implementations might have had. github.com/gobuffalo/packr v1 is an example of a LegacyBox.

type Lister

type Lister interface {
	List() []string
}

type MemoryBox

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

MemoryBox is a thread-safe, in-memory, implementation of the Box interface.

func NewMemoryBox

func NewMemoryBox() *MemoryBox

NewMemoryBox returns a configured *MemoryBox

func (*MemoryBox) AddBytes

func (m *MemoryBox) AddBytes(path string, t []byte) error

func (*MemoryBox) AddString

func (m *MemoryBox) AddString(path string, t string) error

func (*MemoryBox) Find

func (m *MemoryBox) Find(path string) (ret []byte, e error)

func (*MemoryBox) FindString

func (m *MemoryBox) FindString(path string) (string, error)

func (*MemoryBox) Has

func (m *MemoryBox) Has(path string) bool

func (*MemoryBox) List

func (m *MemoryBox) List() []string

func (*MemoryBox) Open

func (m *MemoryBox) Open(path string) (http.File, error)

func (*MemoryBox) Remove

func (m *MemoryBox) Remove(path string)

func (*MemoryBox) Walk

func (m *MemoryBox) Walk(wf WalkFunc) error

func (*MemoryBox) WalkPrefix

func (m *MemoryBox) WalkPrefix(pre string, wf WalkFunc) error

type SimpleFile

type SimpleFile interface {
	fmt.Stringer
	io.Reader
	io.Writer
	Name() string
}

type WalkFunc

type WalkFunc func(string, File) error

type Walkable

type Walkable interface {
	Walker
	WalkPrefix(prefix string, wf WalkFunc) error
}

type Walker

type Walker interface {
	Walk(wf WalkFunc) error
}

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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