Documentation ¶
Index ¶
- Constants
- Variables
- func CreateIf(create Creatable, s string) (err error)
- func SelectAll(_ Pather) bool
- func UseAsScanner(r ReaderCreator, fn func(*bufio.Scanner) error) (err error)
- func UseReader(r ReaderCreator, fn func(io.Reader) error) (err error)
- func UseWriter(w WriterCreator, fn func(io.Writer) error) (err error)
- type BufferedCreator
- type BufferedReadCloser
- type ByModTime
- type CloseError
- type Convertable
- type Creatable
- type Dir
- type EmptyDir
- type EnumFilter
- type ErrorFmt
- type Extension
- type File
- type Filter
- type Filterer
- type FiltererPayload
- type Filters
- type From
- type Glob
- type GlobPattern
- type GlobPatterns
- type GlobResult
- type Globber
- type IndexedFrom
- type Like
- type MustHaveExtension
- type NotExists
- type Operations
- type Parts
- type Path
- func (p Path) Abs() (l Like, err error)
- func (p Path) AddExtension(ext string) (l Like)
- func (p Path) AsPath() (rp Path)
- func (p Path) Base() (l Like)
- func (p Path) Create() (of *os.File, err error)
- func (p Path) Dir() (pp Path)
- func (p Path) Exists() (b bool, err error)
- func (p Path) Extension() (ext Extension)
- func (p Path) Fail(efmt ErrorFmt, err error) (Err error)
- func (p Path) GetPath() string
- func (p Path) Glob() (v []Valid, err error)
- func (p Path) Hash(h hash.Hash)
- func (p Path) IfExists() (optPath *Valid, err error)
- func (p Path) Into(f From) (err error)
- func (p Path) Join(args ...string) (l Like)
- func (p Path) Len() int
- func (p Path) MarshalJSON() (b []byte, err error)
- func (p Path) Mkdir() (d Dir, err error)
- func (p Path) MustExist() (err error)
- func (p Path) NoExtension() (l Like)
- func (p Path) Remove() (err error)
- func (p *Path) Set(s string) (err error)
- func (p Path) String() string
- func (p Path) ToDir() (d Dir, err error)
- func (p Path) ToFile() (f File, err error)
- func (p Path) ToValid() (vp Valid, err error)
- func (p Path) ToValidFile() (vf ValidFile, err error)
- func (p Path) Touch() (err error)
- func (p *Path) UnmarshalJSON(b []byte) (err error)
- type Pather
- type ReaderCreator
- type Retreiver
- type Scanner
- type SelectDir
- type SelectFile
- type Transform
- type Transformer
- type Transforms
- type Valid
- func (v *Valid) FromPath(p Pather) (err error)
- func (vp Valid) IsDir() (b bool, err error)
- func (vp Valid) ModTime() (t time.Time, err error)
- func (vp Valid) Move(dir Dir) (dst Valid, err error)
- func (v Valid) OlderThan(vp Valid) (b bool, err error)
- func (vp Valid) Open() (of *os.File, err error)
- func (vp Valid) Remove() (err error)
- func (vp Valid) Rename(target fmt.Stringer) (dst Valid, err error)
- func (v *Valid) Set(s string) (err error)
- func (vp Valid) Stat() (fi os.FileInfo, err error)
- func (v Valid) ToFile() (vf ValidFile, err error)
- func (v *Valid) UnmarshalJSON(b []byte) (err error)
- func (v Valid) YoungerThan(vp Valid) (b bool, err error)
- type ValidFile
- func (v *ValidFile) FromPath(p Pather) (err error)
- func (vf ValidFile) LoadJson(val interface{}) (err error)
- func (vf ValidFile) Move(d Dir) (vfm ValidFile, err error)
- func (vf ValidFile) ReadAll() (b []byte, err error)
- func (vf ValidFile) Scanner() (s Scanner, err error)
- func (vf ValidFile) ToFile() (f File)
- func (v ValidFile) Use(fn func(*os.File) error) (err error)
- type ValidFiles
- type Validator
- type Valids
- type WithExtension
- type WriterCreator
- type WrongExtension
Constants ¶
const ( OpCreate operation = iota OpCreateAbs OpStat OpExists )
const (
DirCreate dirOperation = iota
)
const (
OpOpen validPathOperation = iota
)
Variables ¶
var Error pathError
Functions ¶
func UseAsScanner ¶
func UseAsScanner(r ReaderCreator, fn func(*bufio.Scanner) error) (err error)
UseAsScanner creates a ReaderCloser and wraps it inside a bufio.Scanner struct to be used by fn.
func UseReader ¶
func UseReader(r ReaderCreator, fn func(io.Reader) error) (err error)
UseReader creates a ReadCloser object, applies the fn function to it (uses the resource), and finally closes it. This ensures that the error reported by the Close method is returned and not ignored and clearly denotes the lifetime of a ReadCloser instance.
Types ¶
type BufferedCreator ¶
type BufferedCreator struct {
// contains filtered or unexported fields
}
func (BufferedCreator) CreateReader ¶
func (b BufferedCreator) CreateReader() (reader io.ReadCloser, err error)
type BufferedReadCloser ¶
type BufferedReadCloser struct { io.ReadCloser *bufio.Reader }
type CloseError ¶
type CloseError struct {
// contains filtered or unexported fields
}
func (CloseError) Error ¶
func (ce CloseError) Error() (s string)
type Convertable ¶
type Extension ¶
type Extension string
func (Extension) Files ¶
func (e Extension) Files(num int) (w WithExtension)
type FiltererPayload ¶
type FiltererPayload struct {
Filterer
}
func (*FiltererPayload) UnmarshalJSON ¶
func (f *FiltererPayload) UnmarshalJSON(b []byte) (err error)
type GlobPattern ¶
type GlobPattern struct {
// contains filtered or unexported fields
}
func (GlobPattern) Glob ¶
func (g GlobPattern) Glob() (gr GlobResult, err error)
func (*GlobPattern) UnmarshalJSON ¶
func (g *GlobPattern) UnmarshalJSON(b []byte) (err error)
type GlobPatterns ¶
type GlobPatterns map[string]GlobPattern
type GlobResult ¶
type GlobResult struct {
// contains filtered or unexported fields
}
func (GlobResult) Into ¶
func (g GlobResult) Into(in IndexedFrom) (err error)
func (GlobResult) Len ¶
func (g GlobResult) Len() (n int)
type Globber ¶
type Globber struct { Valid Valid `json:"path"` Pattern string `json:"pattern"` Filterer FiltererPayload `json:"select"` }
type IndexedFrom ¶
type Like ¶
type Like interface { Convertable Operations }
type MustHaveExtension ¶
type MustHaveExtension Extension
type Operations ¶
type Parts ¶
type Parts struct {
// contains filtered or unexported fields
}
func (*Parts) UnmarshalJSON ¶
type Path ¶
type Path struct {
// contains filtered or unexported fields
}
func (Path) AddExtension ¶
func (Path) MarshalJSON ¶
func (Path) NoExtension ¶
func (Path) ToValidFile ¶
func (*Path) UnmarshalJSON ¶
type ReaderCreator ¶
type ReaderCreator interface {
CreateReader() (r io.ReadCloser, err error)
}
ReadCreator represents an object that can create a ReadCloser.
type Retreiver ¶
type Retreiver struct {
// contains filtered or unexported fields
}
func NewRetreiver ¶
type SelectFile ¶
type SelectFile struct{}
type Transformer ¶
type Transforms ¶
type Transforms []Transform
type ValidFiles ¶
type ValidFiles []ValidFile
func (ValidFiles) GetFrom ¶
func (v ValidFiles) GetFrom(ii int) (f From)
type WithExtension ¶
type WithExtension struct {
// contains filtered or unexported fields
}
WithExtension represents a slice of files that have the proper extension. Implements the IndexedFrom interface. An easy way to generate a slice of valid file paths with the right extension.
func (WithExtension) Files ¶
func (w WithExtension) Files() (files []ValidFile)
Files returns the valid file paths that have the right extension.
func (WithExtension) GetFrom ¶
func (w WithExtension) GetFrom(ii int) (f From)
type WriterCreator ¶
type WriterCreator interface {
CreateWriter() (io.WriteCloser, error)
}
type WrongExtension ¶
type WrongExtension struct { // The expected extension. Expected Extension // The extension we got. Got Extension // The file with the wrong extension. File ValidFile }
WrongExtension represents an error that occurs when a valid file does not have the proper extension.
func (WrongExtension) Error ¶
func (e WrongExtension) Error() (s string)