Documentation
¶
Overview ¶
Package filer is an interface used in the rotatorr subpackages. You may override this to gain more control of operations in your app.
Index ¶
- type File
- func (f *File) MkdirAll(path string, perm os.FileMode) error
- func (f *File) OpenFile(name string, flag int, perm os.FileMode) (*os.File, error)
- func (f *File) ReadDir(dirname string) ([]os.FileInfo, error)
- func (f *File) Remove(fileName string) error
- func (f *File) Rename(fileName, newPath string) error
- func (f *File) Stat(filename string) (*FileInfo, error)
- type FileInfo
- type Filer
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type File ¶
type File struct{}
File can be embedded in a custom type to provide the missing methods for the Filer interface.
Example ¶
package main import ( "fmt" "golift.io/rotatorr/filer" ) // Our interface must satify a filer.Filer. var _ filer.Filer = (*MyFiler)(nil) // Create a custom Filer that overrides only the Rename method. type MyFiler struct { filer.File } func (f *MyFiler) Rename(oldpath, newpath string) error { fmt.Printf("Renamed %s -> %s\n", oldpath, newpath) return nil } func main() { // Pass s into any package that uses a filer.Filer. s := &MyFiler{} _ = s.Rename("old.file", "new.file") }
Output: Renamed old.file -> new.file
type FileInfo ¶
FileInfo contains normal os.FileInfo + file creation time. Created by Stat(). Sorry in advance.
type Filer ¶
type Filer interface { Remove(fileName string) error Rename(fileName, newPath string) error ReadDir(dirPath string) ([]os.FileInfo, error) MkdirAll(path string, perm os.FileMode) error OpenFile(name string, flag int, perm os.FileMode) (*os.File, error) Stat(filename string) (*FileInfo, error) }
Filer is used to override file-managing procedures.
Click to show internal directories.
Click to hide internal directories.