Documentation
¶
Index ¶
- func CheckExist(filePath string, onNonExist func() error) (err error)
- func DataFile(name string) string
- func HumanBytes[T Number](b T) string
- func HumanDuration[T Number](d T) string
- func MathDiv[A, B Number](a A, b B, precision ...int) float64
- func Overwrite(opts *SaveOptions)
- func ReadCloser(read bytesFunc) io.ReadCloser
- func Reader(read bytesFunc) io.Reader
- func Save(src io.Reader, filePath string, opts ...SaveOption) (err error)
- func SetDataDir(path string)
- func UseTempFile(opts *SaveOptions)
- func WriteCloser(write bytesFunc) io.WriteCloser
- func Writer(write bytesFunc) io.Writer
- type Number
- type ProgressHook
- type SaveHook
- type SaveOption
- type SaveOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckExist ¶
func HumanBytes ¶
func HumanDuration ¶
func Overwrite ¶
func Overwrite(opts *SaveOptions)
func ReadCloser ¶
func ReadCloser(read bytesFunc) io.ReadCloser
func SetDataDir ¶
func SetDataDir(path string)
func UseTempFile ¶
func UseTempFile(opts *SaveOptions)
func WriteCloser ¶
func WriteCloser(write bytesFunc) io.WriteCloser
Types ¶
type ProgressHook ¶
type ProgressHook func(cur, total int64)
type SaveOption ¶
type SaveOption func(*SaveOptions)
func AfterSave ¶
func AfterSave(after SaveHook) SaveOption
func BeforeSave ¶
func BeforeSave(before SaveHook) SaveOption
func ConsoleProgress ¶
func ConsoleProgress() SaveOption
func Mode ¶
func Mode(mode fs.FileMode) SaveOption
func Progress ¶
func Progress(report ProgressHook) SaveOption
func TotalBytes ¶
func TotalBytes(total int64) SaveOption
type SaveOptions ¶
type SaveOptions struct { Overwrite bool `json:"overwrite,omitempty"` Mode fs.FileMode `json:"mode,omitempty"` TotalBytes int64 `json:"total_bytes,omitempty"` UseTempFile bool `json:"use_temp_file,omitempty"` Progress ProgressHook `json:"-"` BeforeSave []SaveHook `json:"-"` AfterSave []SaveHook `json:"-"` }
func (*SaveOptions) With ¶
func (options *SaveOptions) With(opts ...SaveOption) *SaveOptions
Click to show internal directories.
Click to hide internal directories.