tool

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(args ...interface{})

func DebugFields

func DebugFields(fields Field, args ...interface{})

func DefaultCache added in v0.0.4

func DefaultCache(file string) *_Cache

DefaultCache 获取一个默认的key-value缓存对象,默认超时5分钟,清理10分钟

func Error

func Error(args ...interface{})

func ErrorFields

func ErrorFields(fields Field, args ...interface{})

func Fatal

func Fatal(args ...interface{})

func FatalFields

func FatalFields(fields Field, args ...interface{})

func GetUserHome

func GetUserHome() string

GetUserHome 获取用户家目录

func Info

func Info(args ...interface{})

func InfoFields

func InfoFields(fields Field, args ...interface{})

func LogError

func LogError(msg string, err error)

func Md5Byte

func Md5Byte(text []byte, salt ...string) string

Md5Byte MD5加密byte数组

func Md5File

func Md5File(f File) string

Md5File 获取文件MD5值

func Md5String

func Md5String(text string, salt ...string) string

Md5String MD5加密字符创

func NewCache added in v0.0.4

func NewCache(file string, defaultExpiration, cleanupInterval time.Duration) *_Cache

DefaultCache 获取一个key-value缓存对象

func Panic

func Panic(args ...interface{})

func PanicFields

func PanicFields(fields Field, args ...interface{})

func SetLogLevel

func SetLogLevel(level string)

func Trace

func Trace(args ...interface{})

func TraceFields

func TraceFields(fields Field, args ...interface{})

func UuidEqual

func UuidEqual(value1 uuid.UUID, value2 uuid.UUID) bool

func UuidFromByte

func UuidFromByte(input []byte) uuid.UUID

func UuidFromString

func UuidFromString(input string) uuid.UUID

func UuidV1

func UuidV1() uuid.UUID

func UuidV4

func UuidV4() uuid.UUID

func Warn

func Warn(args ...interface{})

func WarnFields

func WarnFields(fields Field, args ...interface{})

Types

type Field

type Field logrus.Fields

type File

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

File 文件结构体,封装简化操作

func NewFile

func NewFile(path string, flag int, perm os.FileMode) (*File, error)

NewFile 获取文件

func NewFileDefault added in v0.0.4

func NewFileDefault(path string) (*File, error)

NewFileDefault 默认权限获取文件

func (*File) AbsolutePath

func (f *File) AbsolutePath() string

AbsolutePath 获取绝对路径

func (*File) BufWriter

func (f *File) BufWriter(cb func(writer *bufio.Writer, err error))

BufWriter 写入文件

func (*File) CreateFile

func (f *File) CreateFile() bool

CreateFile 创建文件

func (*File) Exists

func (f *File) Exists() bool

Exists 文件或文件夹是否存在

func (*File) Extension

func (f *File) Extension() string

Extension 获取文件扩展名

func (*File) FileName

func (f *File) FileName() string

FileName 获取文件名

func (*File) GetParent

func (f *File) GetParent() (*File, error)

GetParent 获取父目录

func (*File) IsDir

func (f *File) IsDir() bool

IsDir 是否是目录

func (*File) IsFile

func (f *File) IsFile() bool

===Desc:文件相关=========================================================== IsFile 是否是文件

func (*File) MkDir

func (f *File) MkDir() bool

MkDir 创建目录

func (*File) MkDirAll

func (f *File) MkDirAll() bool

MkDirAll 创建目录

func (*File) ReadBytes

func (f *File) ReadBytes(cb func(content []byte, err error))

ReadBytes 读取文件byte数组

func (*File) ReadString

func (f *File) ReadString(cb func(content string, err error))

ReadString 读取文件字符串

func (*File) Remove

func (f *File) Remove() bool

Remove 移动文件

func (*File) Rename

func (f *File) Rename(target string) error

Rename 重命名文件

func (*File) SetFileMode

func (f *File) SetFileMode(perm os.FileMode)

SetFileMode 设置文件读写模式

func (*File) SetFlag

func (f *File) SetFlag(flag int)

func (*File) Size

func (f *File) Size() int64

Size 文件大小

Jump to

Keyboard shortcuts

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