Documentation ¶
Overview ¶
Package files implements utility routines for finding and reading files.
Index ¶
- Variables
- func Exists(pathElems ...string) (bool, error)
- func ExistsFolder(pathElems ...string) (bool, error)
- func Read(pathElems ...string) ([]byte, error)
- func ReadJSON(v interface{}, pathElems ...string) error
- func ReadTOML(v interface{}, pathElems ...string) error
- func ReadUnmarshal(unmarshal UnmarshalFunc, v interface{}, pathElems ...string) error
- func ReadXML(v interface{}, pathElems ...string) error
- func ReadYAML(v interface{}, pathElems ...string) error
- func Rm(pathElems ...string) error
- func WalkUp(startdir string, walker WalkUpFunc) (string, error)
- type UnmarshalFunc
- type WalkUpFunc
Constants ¶
This section is empty.
Variables ¶
var ( ErrDirNotFound = errors.New("no directory found during walk") ErrStopWalk = errors.New("WalkUp: stop") )
Functions ¶
func ExistsFolder ¶
func ReadUnmarshal ¶
func ReadUnmarshal(unmarshal UnmarshalFunc, v interface{}, pathElems ...string) error
ReadUnmarshal reads a file and then unmarshals its contents using an UnmarshalFunc.
func WalkUp ¶ added in v0.7.0
func WalkUp(startdir string, walker WalkUpFunc) (string, error)
WalkUp takes a starting directory and a WalkUpFunc, and calls the function, passing each ancestor of the starting directory in upwards order until the filesystem root is reached.
If the function returns ErrStopWalk, then WalkUp stops and returns the current directory name. If the function returns any other error, then WalkUp stops and that error is returned as the error of WalkUp. If ErrStopWalk is never returned, WalkUp returns ErrDirNotFound.
Types ¶
type UnmarshalFunc ¶
An UnmarshalFunc is a function for unmarshalling bytes into values.
type WalkUpFunc ¶ added in v0.7.0
A WalkUpFunc takes a directory and returns an error.