dutils

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2023 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateFile

func CreateFile(inputPath string) (*os.File, error)

CreateFile 创建文件 inputPath 指定路径 return error:

func CreatePath

func CreatePath(inputPath string) error

CreatePath 创建目录 inputPath 指定路径 return true:创建目录成功,false::创建目录失败

func DiskFreeCheck

func DiskFreeCheck(path string) uint64

DiskFreeCheck 获得磁盘剩余空间大小

func ErgodicDir

func ErgodicDir(inputPath string) (dirList []string, err error)

ErgodicDir 遍历指定目录中所有的文件夹 inputPath 需要遍历的目录 return dirList 该目录下所有的文件夹, err 错误

func ErgodicExtFile

func ErgodicExtFile(inputPath string, ext string) (fileList []string, err error)

ErgodicExtFile 遍历指定目录中指定后缀的文件 inputPath 需要遍历的目录 ext 后缀名,例如“.txt" return fileList 符合要求的文件列表, err 错误

func ErgodicFile

func ErgodicFile(inputPath string) (fileList []string, err error)

ErgodicFile 遍历指定目录中的文件 inputPath 需要遍历的目录 return fileList 符合要求的文件列表, err 错误

func Exist

func Exist(inputPath string) bool

Exist 判断目录或文件是否存在 inputPath 指定路径 返回true:文件或目录存在 返回false:文件或目录不存在

func GenDayTimeStamp

func GenDayTimeStamp() string

GenDayTimeStamp 生成当前时间戳,精确到天 格式为2006-01-02ns

func GenMicrosecondTimeStamp

func GenMicrosecondTimeStamp() string

GenMicrosecondTimeStamp 生成当前时间戳,精确到微秒 格式为2006-01-02 15:04:05.000000

func GenMillisecondTimeStamp

func GenMillisecondTimeStamp() string

GenMillisecondTimeStamp 生成当前时间戳,精确到毫秒 格式为2006-01-02 15:04:05.000

func GenMinuteTimeStamp

func GenMinuteTimeStamp() string

GenMinuteTimeStamp 生成当前时间戳,精确到分 格式为2006-01-02 15:04

func GenSecondTimeStamp

func GenSecondTimeStamp() string

GenSecondTimeStamp 生成当前时间戳,精确到秒 格式为2006-01-02 15:04:05

func GenUUID

func GenUUID() string

GenUUID 生成唯一识别码 格式为6b626e40-12a5-4a1a-87c2-b3a7f904a93c

func GenVerificationCode

func GenVerificationCode(size int) string

func GetFreePort

func GetFreePort() string

func GetHomePath

func GetHomePath() string

GetHomePath 获得用户目录 return 用户根目录

func ImageRaw2Png

func ImageRaw2Png(raw []byte, width, height int) ([]byte, error)

func MD5

func MD5(inputPath string) (string, error)

MD5 计算文件16位md5

func MD5FromByte

func MD5FromByte(data []byte) string

MD5FromByte 计算文件16位md5

func MD5FromString

func MD5FromString(data string) string

MD5FromString 计算文件16位md5

func MustMD5

func MustMD5(inputPath string) string

MustMD5 计算文件16位md5

func MustSliceStringToInt32

func MustSliceStringToInt32(in []string) []int32

func Ok

func Ok() bool

func OpenFile

func OpenFile(path string, create, forWrite bool) (file *os.File, err error)

OpenFile 打开文件 inputPath 指定路径 forWrite 是否可写 返回 file 文件指针,err,错误

func ParseAllTime

func ParseAllTime(stamp string) (time.Time, bool)

func ParseDayTime

func ParseDayTime(stamp string) (time.Time, bool)

func ParseHourTime

func ParseHourTime(stamp string) (time.Time, bool)

func ParseMicrosecondTime

func ParseMicrosecondTime(stamp string) (time.Time, bool)

func ParseMillisecondTime

func ParseMillisecondTime(stamp string) (time.Time, bool)

func ParseMinuteTime

func ParseMinuteTime(stamp string) (time.Time, bool)

func ParseMonthTime

func ParseMonthTime(stamp string) (time.Time, bool)

func ParseSecondTime

func ParseSecondTime(stamp string) (time.Time, bool)

func ParseYearTime

func ParseYearTime(stamp string) (time.Time, bool)

func Pgm2Png

func Pgm2Png(pgmRaw []byte) ([]byte, error)

func RandomString

func RandomString() string

RandomString 生成随机数字符串

func Read

func Read(inputPath string) (string, error)

Read 读取指定文件的内容 inputPath 指定路径 @return 数据内容和错误码

func ReadByte

func ReadByte(inputPath string) ([]byte, error)

ReadByte 读取指定文件的内容 inputPath 指定路径 @return 数据内容和错误码

func ReadToB64

func ReadToB64(path string) (string, error)

ReadToB64 读取文件,输出为base64 inputPath 指定路径 @return base64格式的数据内容

func RecursiveErgodicExtFile

func RecursiveErgodicExtFile(inputPath string, ext string) (fileListDir []string, err error)

RecursiveErgodicExtFile 遍历指定目录中的文件 inputPath 需要遍历的目录 return fileListDir 符合要求的文件列表(包含目录), err 错误

func RecursiveErgodicFile

func RecursiveErgodicFile(inputPath string) (fileListDir []string, err error)

RecursiveErgodicFile 遍历指定目录中的文件 inputPath 需要遍历的目录 return fileListDir 符合要求的文件列表(包含目录), err 错误

func Remove

func Remove(path string) error

Remove 删除目录或文件 inputPath 指定路径 return error

func ReportK8sProbeError

func ReportK8sProbeError(msg string)

func RunK8sHttpProbe

func RunK8sHttpProbe(path string, port string)

func Sha256

func Sha256(raw []byte) string

Sha256 计算输入的sha256值

func Sha256FromFile

func Sha256FromFile(path string) string

func Sha512

func Sha512(raw string) string

Sha512 计算输入的sha512值

func SignalCtx added in v0.9.1

func SignalCtx(ctx context.Context) context.Context

func Size

func Size(inputPath string) int64

Size 获得文件大小,单位byte

func Sleep

func Sleep(seconds float32)

Sleep sleep一定时间 单位为秒

func Startpprof

func Startpprof(port string)

func TimeCost

func TimeCost() func()

func ToMinuteTimeStamp

func ToMinuteTimeStamp(t time.Time) string

func ToString

func ToString(input ...interface{}) string

func Unzip

func Unzip(data []byte, basePath string) error

func Wait

func Wait()

Wait 提供阻塞的循环,用于保持线程

func Write

func Write(inputPath string, data []byte) error

Write 向指定文件写入内容 inputPath 指定路径 data 数据内容 @return 写入结果错误码

func WriteFromB64

func WriteFromB64(inputPath, data string) error

WriteFromB64 向指定文件写入内容 inputPath 指定路径 data 数据内容 @return 写入结果错误码

func Zip

func Zip(write io.ReadWriter, files []ZipFile)

Types

type PGM

type PGM struct {
	Width  int
	Height int
	Data   []byte
}

func ParsePGM

func ParsePGM(raw []byte) (*PGM, error)

type ZipFile

type ZipFile struct {
	Path string //file relative path
	Data []byte //file data
}

Jump to

Keyboard shortcuts

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