utils

package
v0.6.0-beta.20220429.1200 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2022 License: BSD-3-Clause Imports: 43 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CronUtils = cronUtils{
	// contains filtered or unexported fields
}
View Source
var TaskExecChanMap = NewChanMap()

Functions

func BackoffErrorNotify added in v0.6.0

func BackoffErrorNotify(prefix string) backoff.Notify

func BsonMEqual added in v0.6.0

func BsonMEqual(v1, v2 bson.M) (ok bool)

func BytesToString

func BytesToString(b []byte) string

func Close

func Close(c io.Closer)

func Compress

func Compress(files []*os.File, dest string) error

压缩文件 files 文件数组,可以是不同dir下的文件或者文件夹 dest 压缩文件存放地址

func ComputeHmacSha256

func ComputeHmacSha256(message string, secret string) string

func Contains

func Contains(array interface{}, val interface{}) (fla bool)

func CopyDir

func CopyDir(src string, dst string) error

Dir copies a whole directory recursively

func CopyFile

func CopyFile(src, dst string) error

File copies a single file from src to dst

func CreateDirPath

func CreateDirPath(filePath string)

创建文件夹

func DeCompress

func DeCompress(srcFile *os.File, dstPath string) error

func DeCompressByPath

func DeCompressByPath(tarFile, dest string) error

func DecryptAES added in v0.6.0

func DecryptAES(src string) (res string, err error)

func DefaultWait added in v0.6.0

func DefaultWait()

func DenormalizeBsonMObjectId added in v0.6.0

func DenormalizeBsonMObjectId(m bson.M) (res bson.M)

func EncryptAES added in v0.6.0

func EncryptAES(src string) (res string, err error)

func EncryptMd5 added in v0.6.0

func EncryptMd5(str string) string

func Exists

func Exists(path string) bool

func FillEmptyFileData added in v0.6.0

func FillEmptyFileData(data []byte) (res []byte)

func ForceInitModule added in v0.6.0

func ForceInitModule(fn func() error) (err error)

func GetAllFilesFromDir

func GetAllFilesFromDir(dirPath string) ([]*os.File, error)

func GetArrayItems added in v0.6.0

func GetArrayItems(array interface{}) (res []interface{}, err error)

func GetFilesFromDir

func GetFilesFromDir(dirPath string) ([]*os.File, error)

func GetFromDbCache added in v0.6.0

func GetFromDbCache(key string, getFn func() (string, error)) (res string, err error)

func GetLocalTime

func GetLocalTime(t time.Time) time.Time

func GetLocalTimeString

func GetLocalTimeString(t time.Time) string

func GetMongoOpts added in v0.6.0

func GetMongoOpts(opts *generic.ListOptions) (res *mongo.FindOptions)

func GetMongoQuery added in v0.6.0

func GetMongoQuery(query generic.ListQuery) (res bson.M)

func GetRpcParam

func GetRpcParam(key string, params map[string]string) string

获取 RPC 参数

func GetSecretKey added in v0.6.0

func GetSecretKey() string

func GetSecretKeyBytes added in v0.6.0

func GetSecretKeyBytes() []byte

func GetSpiderCol

func GetSpiderCol(col string, name string) string

func GetSpiderMd5Str

func GetSpiderMd5Str(file string) string

func GetTimeString

func GetTimeString(t time.Time) string

func GetUserFromArgs added in v0.6.0

func GetUserFromArgs(args ...interface{}) (u interfaces.User)

func InitModule added in v0.6.0

func InitModule(id interfaces.ModuleId, fn func() error) (err error)

func IsCancellable added in v0.6.0

func IsCancellable(status string) bool

func IsDebug added in v0.6.0

func IsDebug() bool

func IsDir

func IsDir(path string) bool

func IsFile

func IsFile(path string) bool

func JsonToBytes added in v0.6.0

func JsonToBytes(d interface{}) (bytes []byte, err error)

func ListDir

func ListDir(path string) []os.FileInfo

func LogDebug added in v0.6.0

func LogDebug(msg string)

func NewUUIDString added in v0.6.0

func NewUUIDString() (res string)

func NormalizeBsonMObjectId added in v0.6.0

func NormalizeBsonMObjectId(m bson.M) (res bson.M)

func ObjectToString

func ObjectToString(params interface{}) string

Object 转化为 String

func OpenFile

func OpenFile(fileName string) *os.File

func ReadFileOneLine

func ReadFileOneLine(fileName string) string

func RemoveFiles

func RemoveFiles(path string)

func ResultToJson added in v0.6.0

func ResultToJson()

func SetFileVariable

func SetFileVariable(filePath string, key string, value string) error

设置文件变量值 可以理解为将文件中的变量占位符替换为想要设置的值

func ShuffleArray added in v0.6.0

func ShuffleArray(slice []interface{}) (err error)

func StringArrayContains

func StringArrayContains(arr []string, str string) bool

func TrimFileData added in v0.6.0

func TrimFileData(data []byte) (res []byte)

func VisualizeContainer added in v0.6.0

func VisualizeContainer(c *dig.Container) (err error)

Types

type ChanMap

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

func NewChanMap

func NewChanMap() *ChanMap

func (*ChanMap) Chan

func (cm *ChanMap) Chan(key string) chan string

func (*ChanMap) ChanBlocked

func (cm *ChanMap) ChanBlocked(key string) chan string

func (*ChanMap) HasChanKey

func (cm *ChanMap) HasChanKey(key string) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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