utils

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2020 License: BSD-3-Clause Imports: 26 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TaskExecChanMap = NewChanMap()

Functions

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

* @zipFile:压缩文件 @dstPath:解压之后文件保存路径

func DeCompressByPath

func DeCompressByPath(tarFile, dest string) error

* @tarFile:压缩文件路径 @dest:解压文件夹

func EncryptPassword

func EncryptPassword(str string) string

func Exists

func Exists(path string) bool

判断所给路径文件/文件夹是否存在

func GetAllFilesFromDir

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

func GetFilesFromDir

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

func GetJson

func GetJson(message entity.NodeMessage) string

func GetLangFromLangNamePlain

func GetLangFromLangNamePlain(name string) entity.Lang

根据语言名获取语言实例,不包含状态

func GetLangList

func GetLangList() []entity.Lang

func GetLangListPlain

func GetLangListPlain() []entity.Lang

获取语言列表

func GetLocalTime

func GetLocalTime(t time.Time) time.Time

func GetLocalTimeString

func GetLocalTimeString(t time.Time) string

func GetMessage

func GetMessage(message redis.Message) *entity.NodeMessage

func GetPackageJsonDeps

func GetPackageJsonDeps(filepath string) (deps []string, err error)

func GetRpcParam

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

获取 RPC 参数

func GetSpiderCol

func GetSpiderCol(col string, name string) string

func GetSpiderMd5Str

func GetSpiderMd5Str(file string) string

func GetSystemScriptPath

func GetSystemScriptPath(scriptName string) string

func GetSystemScripts

func GetSystemScripts() (res []string)

获取系统脚本列表

func GetTimeString

func GetTimeString(t time.Time) string

func InterfaceToString

func InterfaceToString(value interface{}) string

func IsDir

func IsDir(path string) bool

判断所给路径是否为文件夹

func IsFile

func IsFile(path string) bool

判断所给路径是否为文件

func IsObjectIdNull

func IsObjectIdNull(id bson.ObjectId) bool

func ListDir

func ListDir(path string) []os.FileInfo

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 SetFileVariable

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

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

func StringArrayContains

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

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

Jump to

Keyboard shortcuts

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