go.rice: github.com/GeertJohan/go.rice Index | Files | Directories

package rice

import "github.com/GeertJohan/go.rice"

Index

Package Files

appended.go box.go config.go debug.go embedded.go file.go http.go sort.go virtual.go walk.go

Constants

const (
    LocateFS               = LocateMethod(iota) // Locate on the filesystem according to package path.
    LocateAppended                              // Locate boxes appended to the executable.
    LocateEmbedded                              // Locate embedded boxes.
    LocateWorkingDirectory                      // Locate on the binary working directory
)

Variables

var Debug = false

Debug can be set to true to enable debugging.

type Box Uses

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

Box abstracts a directory for resources/files. It can either load files from disk, or from embedded code (when `rice --embed` was ran).

func FindBox Uses

func FindBox(name string) (*Box, error)

FindBox returns a Box instance for given name. When the given name is a relative path, it's base path will be the calling pkg/cmd's source root. When the given name is absolute, it's absolute. derp. Make sure the path doesn't contain any sensitive information as it might be placed into generated go source (embedded).

func MustFindBox Uses

func MustFindBox(name string) *Box

MustFindBox returns a Box instance for given name, like FindBox does. It does not return an error, instead it panics when an error occurs.

func (*Box) Bytes Uses

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

Bytes returns the content of the file with given name as []byte.

func (*Box) HTTPBox Uses

func (b *Box) HTTPBox() *HTTPBox

HTTPBox creates a new HTTPBox from an existing Box

func (*Box) IsAppended Uses

func (b *Box) IsAppended() bool

IsAppended indicates wether this box was appended to the application

func (*Box) IsEmbedded Uses

func (b *Box) IsEmbedded() bool

IsEmbedded indicates wether this box was embedded into the application

func (*Box) MustBytes Uses

func (b *Box) MustBytes(name string) []byte

MustBytes returns the content of the file with given name as []byte. panic's on error.

func (*Box) MustString Uses

func (b *Box) MustString(name string) string

MustString returns the content of the file with given name as string. panic's on error.

func (*Box) Name Uses

func (b *Box) Name() string

Name returns the name of the box

func (*Box) Open Uses

func (b *Box) Open(name string) (*File, error)

Open opens a File from the box If there is an error, it will be of type *os.PathError.

func (*Box) String Uses

func (b *Box) String(name string) (string, error)

String returns the content of the file with given name as string.

func (*Box) Time Uses

func (b *Box) Time() time.Time

Time returns how actual the box is. When the box is embedded, it's value is saved in the embedding code. When the box is live, this methods returns time.Now()

func (*Box) Walk Uses

func (b *Box) Walk(path string, walkFn filepath.WalkFunc) error

Walk is like filepath.Walk() Visit http://golang.org/pkg/path/filepath/#Walk for more information

type Config Uses

type Config struct {
    // LocateOrder defines the priority order that boxes are searched for. By
    // default, the package global FindBox searches for embedded boxes first,
    // then appended boxes, and then finally boxes on the filesystem.  That
    // search order may be customized by provided the ordered list here. Leaving
    // out a particular method will omit that from the search space. For
    // example, []LocateMethod{LocateEmbedded, LocateAppended} will never search
    // the filesystem for boxes.
    LocateOrder []LocateMethod
}

Config allows customizing the box lookup behavior.

func (*Config) FindBox Uses

func (c *Config) FindBox(boxName string) (*Box, error)

FindBox searches for boxes using the LocateOrder of the config.

func (*Config) MustFindBox Uses

func (c *Config) MustFindBox(boxName string) *Box

MustFindBox searches for boxes using the LocateOrder of the config, like FindBox does. It does not return an error, instead it panics when an error occurs.

type File Uses

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

File implements the io.Reader, io.Seeker, io.Closer and http.File interfaces

func (*File) Close Uses

func (f *File) Close() error

Close is like (*os.File).Close() Visit http://golang.org/pkg/os/#File.Close for more information

func (*File) Read Uses

func (f *File) Read(bts []byte) (int, error)

Read is like (*os.File).Read() Visit http://golang.org/pkg/os/#File.Read for more information

func (*File) Readdir Uses

func (f *File) Readdir(count int) ([]os.FileInfo, error)

Readdir is like (*os.File).Readdir() Visit http://golang.org/pkg/os/#File.Readdir for more information

func (*File) Readdirnames Uses

func (f *File) Readdirnames(count int) ([]string, error)

Readdirnames is like (*os.File).Readdirnames() Visit http://golang.org/pkg/os/#File.Readdirnames for more information

func (*File) Seek Uses

func (f *File) Seek(offset int64, whence int) (int64, error)

Seek is like (*os.File).Seek() Visit http://golang.org/pkg/os/#File.Seek for more information

func (*File) Stat Uses

func (f *File) Stat() (os.FileInfo, error)

Stat is like (*os.File).Stat() Visit http://golang.org/pkg/os/#File.Stat for more information

type HTTPBox Uses

type HTTPBox struct {
    *Box
}

HTTPBox implements http.FileSystem which allows the use of Box with a http.FileServer.

e.g.: http.Handle("/", http.FileServer(rice.MustFindBox("http-files").HTTPBox()))

func (*HTTPBox) Open Uses

func (hb *HTTPBox) Open(name string) (http.File, error)

Open returns a File using the http.File interface

type LocateMethod Uses

type LocateMethod int

LocateMethod defines how a box is located.

type SortByModified Uses

type SortByModified []os.FileInfo

SortByModified allows an array of os.FileInfo objects to be easily sorted by modified date using sort.Sort(SortByModified(array))

func (SortByModified) Len Uses

func (f SortByModified) Len() int

func (SortByModified) Less Uses

func (f SortByModified) Less(i, j int) bool

func (SortByModified) Swap Uses

func (f SortByModified) Swap(i, j int)

type SortByName Uses

type SortByName []os.FileInfo

SortByName allows an array of os.FileInfo objects to be easily sorted by filename using sort.Sort(SortByName(array))

func (SortByName) Len Uses

func (f SortByName) Len() int

func (SortByName) Less Uses

func (f SortByName) Less(i, j int) bool

func (SortByName) Swap Uses

func (f SortByName) Swap(i, j int)

Directories

PathSynopsis
embeddedPackage embedded defines embedded data types that are shared between the go.rice package and generated code.
example
rice

Package rice imports 16 packages (graph) and is imported by 437 packages. Updated 2019-03-21. Refresh now. Tools for package owners.