utils

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertModel

func ConvertModel(src, dst any)

func CopyDir added in v0.6.0

func CopyDir(fs embed.FS, src, dst string, replace bool, skip bool)
func CreateLink(src, dst string) error

func CreateMutiDir

func CreateMutiDir(filePath string) error

CreateMutiDir 调用os.MkdirAll递归创建文件夹

func FileSize added in v0.6.0

func FileSize(path string) int64

FileSize 获取文件大小,文件不存返回-1

func FindScript added in v0.6.0

func FindScript(file, ext string) string

FindScript

@Description: 判断插件是否存在
@Description: 如ext='.py',插件名可以忽略'.py'后缀;插件名也可以使用上层文件夹名,会自动加载文件夹内部的 'main.py'
@Description: 如设置为 'plugin/test',会依次尝试加载 'plugin/test/main.py', 'plugin/test.py'
@param file string
@param ext string
@return string

func Format

func Format(format string, p map[string]any) string

func IsDir added in v0.4.1

func IsDir(path string) bool

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

func IsExist

func IsExist(path string) bool

IsExist 判断所给路径文件/文件夹是否存在(返回true是存在)

func MapToStruct added in v0.7.4

func MapToStruct(src map[string]any, dst any)

func Md5Str

func Md5Str(str string) string

func RandString added in v0.7.1

func RandString(n int) string

func Rename added in v0.5.0

func Rename(src, dst string) error

func Sha256

func Sha256(src string) string

func Sleep

func Sleep(second int, ctx context.Context) bool

Sleep

@Description: 信号计时器,每秒检测一次信号,避免长时间等待无法接收信号
@Description: 收到exit信号后,会返回true;倒计时结束,会返回false
@param second int
@param exit chan bool
@return bool

func StructToMap added in v0.7.4

func StructToMap(src any) (dst map[string]any)

func Tag added in v0.6.5

func Tag(tagSrc string, airDate string, ep int) string

func UTCToTimeStr added in v0.4.3

func UTCToTimeStr(t1 string) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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