Documentation ¶
Index ¶
- Variables
- func AllSubfolders(dir string) ([]string, error)
- func CreateFile(fp string, force bool) error
- func CreateFileRecursively(fp string) (*os.File, error)
- func EnsureDir(path string) error
- func ExcludeExt(filename string) string
- func Exists(path string) (bool, error)
- func FileSync(fp string, content []byte) error
- func IsDir(path string) bool
- func IsEmpty(path string) (bool, error)
- func IsFile(path string) bool
- func IsHiddenFile(f os.FileInfo) bool
- func IsSymlink(path string) bool
- func ProcessLine(r io.Reader, handler func(line string) bool) error
- func SimpleExists(path string) bool
- func WriteFile(filename string, content []byte) error
- func WriteToFile(fp string, content []byte) error
- type FileSyncReq
- type FileSyncer
Constants ¶
This section is empty.
Variables ¶
var (
ErrFileExists = errors.New("file exists")
)
Functions ¶
func AllSubfolders ¶
AllSubfolders gets all subfolders under given dir. Hidden folders are ignored.
func CreateFile ¶
CreateFile create a new file with given path. If directory does not exist, return error. If force is true, will truncate existing one. Otherwise, will throw FileExist error.
func CreateFileRecursively ¶
CreateFileRecursively - create file anyway, if file exists, empty it and return.
func ExcludeExt ¶
ExcludeExt returns filename without extension
func IsHiddenFile ¶
IsHiddenFile checks whether the file is hidden, that's, starts with ".".
func ProcessLine ¶
ProcessLine reads the lines from reader and apply each line to handler. If handler returns false, stop consuming remaining lines. NOTE: Max allowed line size is 2M bytes. https://devmarkpro.com/working-big-files-golang
func SimpleExists ¶
SimpleExists reports whether the given path exists.
func WriteToFile ¶
Types ¶
type FileSyncReq ¶
FileSyncer writes bytes to file. using only one goroutine for performance.
type FileSyncer ¶
type FileSyncer struct {
// contains filtered or unexported fields
}
func NewFileSyncer ¶
func NewFileSyncer(capacity int) *FileSyncer