util

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2023 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckProcessExist

func CheckProcessExist(pid int) bool

func CopyFile added in v1.0.0

func CopyFile(source, destination string) error

CopyFile 将一个目录复制到另外一个目录中

func CopyFolder added in v1.0.0

func CopyFolder(source, destination string) error

CopyFolder 将一个目录复制到另外一个目录中

func CreateFileTemlate

func CreateFileTemlate(folderNeedCreate bool, folderPath string, file string, tmp string, data interface{}) error

folderNeedCreate 表明路径是否需要创建 folderPath/file 确定了目标文件的路径 tmp 为模板字符串, data为数据

func DownloadFile

func DownloadFile(filepath string, url string) error

DownloadFile will download a url to a local file. It's efficient because it will write as it downloads and not load the whole file into memory.

func Exists

func Exists(path string) bool

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

func GetExecDirectory

func GetExecDirectory() string

GetExecDirectory 获取当前执行程序目录

func IsHiddenDirectory

func IsHiddenDirectory(path string) bool

路径是否是隐藏路径

func KillPid added in v1.0.0

func KillPid(pid int) error

func PrettyPrint

func PrettyPrint(arr [][]string)

PrettyPrint 美观输出数组

func RebuildApp added in v1.0.0

func RebuildApp() error

func ResolveRateLimitErrorByAuth added in v1.0.6

func ResolveRateLimitErrorByAuth(err error) (*github.Client, error)

func SafeGo added in v1.0.6

func SafeGo(ctx context.Context, handler func())

SafeGo 进行安全的goroutine调用 SafeGo 启动的goroutine不会因为函数返回error或者异常导致请求异常,相关的 panic 信息会通过日志服务打印

func SafeGoAndWait added in v1.0.6

func SafeGoAndWait(ctx context.Context, handlers ...func() error) error

SafeGoAndWait 进行并发安全并行调用 第一个参数是context接口,如果还实现了Container接口,且绑定了日志服务,则使用日志服务 第二个参数是匿名函数handlers数组, 进行最终的业务逻辑 返回handlers中任何一个错误(如果handlers中有业务逻辑返回错误)

func SubDir

func SubDir(folder string) ([]string, error)

输出所有子目录,目录名

func ToTitleCamel added in v1.0.6

func ToTitleCamel(word string) string

ToTitleCamel 将下划线分割的字符串转换为驼峰字符串 class_id => ClassId

func Unzip

func Unzip(src string, dest string) ([]string, error)

Unzip will decompress a zip archive, moving all files and folders within the zip file (parameter 1) to an output directory (parameter 2).

Types

This section is empty.

Jump to

Keyboard shortcuts

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