Adds FindFs and MustFindFs for the RiceFs.
This commit is contained in:
parent
9049abc682
commit
2985b28851
17
ricefs/fs.go
17
ricefs/fs.go
@ -11,10 +11,27 @@ import (
|
|||||||
|
|
||||||
var _ afero.Fs = &RiceFs{}
|
var _ afero.Fs = &RiceFs{}
|
||||||
|
|
||||||
|
// FindFs tries to find a rice.Box by its name and wraps in into a RiceFs.
|
||||||
|
func FindFs(name string) (*RiceFs, error) {
|
||||||
|
box, err := rice.FindBox(name)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return NewFs(box), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewFs creates a new RiceFs based on the supplied rice.Box.
|
||||||
func NewFs(b *rice.Box) *RiceFs {
|
func NewFs(b *rice.Box) *RiceFs {
|
||||||
return &RiceFs{b}
|
return &RiceFs{b}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MustFindFs tries to find a rice.Box by its name and wraps in into a RiceFs. If the box is not found the method panics.
|
||||||
|
func MustFindFs(name string) *RiceFs {
|
||||||
|
box := rice.MustFindBox(name)
|
||||||
|
return NewFs(box)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RiceFs represents an afero.Fs based on an underlying rice.Box.
|
||||||
type RiceFs struct {
|
type RiceFs struct {
|
||||||
Box *rice.Box
|
Box *rice.Box
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user