fsutil

package
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 20, 2021 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMaxBytesPerFile = 1024 * 1024 * 20 // 20M
	FlushInterval          = 10               // 10ms
)

Variables

View Source
var (
	ErrCannotRotateFile = errors.New("cannot create rotate file")
)

Functions

func ArchiveGzipFile

func ArchiveGzipFile(srcFile string) error

压缩文件 my.log --> my.log.tar.gz

func CopyFile

func CopyFile(dest, source string) error

CopyFile writes the contents of the given source file to dest.

func EnsureBaseDir

func EnsureBaseDir(baseDir, path string) string

EnsureBaseDir ensures that path is always prefixed by baseDir, allowing for the fact that path might have a Window drive letter in it.

func IsFileExist

func IsFileExist(filename string) bool

IsFileExist test if file exist

func LockFile

func LockFile(f *os.File) error

func ReadFileToLines

func ReadFileToLines(filename string) ([]string, error)

把文件内容按一行一行读取

func ReadToLines

func ReadToLines(rd io.Reader) ([]string, error)

func UniqueDirectory

func UniqueDirectory(path, name string) (string, error)

UniqueDirectory returns "path/name" if that directory doesn't exist. If it does, the method starts appending .1, .2, etc until a unique name is found.

func UnlockFile

func UnlockFile(f *os.File) error

Types

type FileWriter

type FileWriter struct {
	// contains filtered or unexported fields
}

FileWriter with log-rotation and auto-archive

func NewFileWriter

func NewFileWriter(name string, maxBytesPerFile int) *FileWriter

func (*FileWriter) Close

func (w *FileWriter) Close()

func (*FileWriter) Flush

func (w *FileWriter) Flush() error

func (*FileWriter) Init

func (w *FileWriter) Init() error

func (*FileWriter) Write

func (w *FileWriter) Write(b []byte) (int, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL