ioutils

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2023 License: BSD-3-Clause Imports: 20 Imported by: 1

README

ioutils

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareFile added in v0.2.1

func CompareFile(file1, file2 string) (bool, error)

func Copy added in v0.1.3

func Copy(src, dst string) (cnt int64, err error)

func DownloadWithDir

func DownloadWithDir(ctx context.Context, srcUrl string, targetDir string, funcs ...func(length, downloaded int64)) (err error)

将文件下载存储到指定目录

func DownloadWithDirAndName

func DownloadWithDirAndName(ctx context.Context, srcUrl string, targetDir string, targetName string, funcs ...func(length, downloaded int64)) (err error)

下载文件

func DownloadWithPath

func DownloadWithPath(ctx context.Context, srcUrl string, targetPath string, funcs ...func(length, downloaded int64)) (err error)

将文件下载存储到指定路径

func Exists

func Exists(name string) bool

Exists reports whether the named file or directory exists.

func GbkToUtf8 added in v0.1.9

func GbkToUtf8(s []byte) ([]byte, error)

func GetExecParentDir added in v0.2.0

func GetExecParentDir() (result string, err error)

func InitLogger added in v0.1.5

func InitLogger(toConsole bool, toFile bool, logRoot string) (logger *zerolog.Logger, err error)

func IsDir

func IsDir(dir string) bool

func PureName

func PureName(name string) string

func RecordData added in v0.0.6

func RecordData(recorder *Recorder, data interface{}) (err error)

写入已经json序列化好的字符数组,字符串或者是可以进行json序列化的对象

func SetRecordWriter added in v0.0.9

func SetRecordWriter(recorder *Recorder, writer Writer)

func Utf8ToGbk added in v0.1.9

func Utf8ToGbk(s []byte) ([]byte, error)

Types

type FileWriter added in v0.0.9

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

func NewFileWriter added in v0.1.0

func NewFileWriter(file *os.File) *FileWriter

func (*FileWriter) Close added in v0.0.9

func (writer *FileWriter) Close() (err error)

func (*FileWriter) Sync added in v0.0.9

func (writer *FileWriter) Sync() (err error)

func (*FileWriter) Write added in v0.0.9

func (writer *FileWriter) Write(b []byte) (n int, err error)

type Recorder added in v0.0.6

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

func StartRecorder added in v0.0.6

func StartRecorder(ctx context.Context, writer Writer) *Recorder

开启存储数据的服务,并返回对象用于后续写数据

type Writer added in v0.0.9

type Writer interface {
	Write(b []byte) (n int, err error)
	Sync() error
	Close() error
}

Jump to

Keyboard shortcuts

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