util

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxScanTokenSize = 1024 * 1024 // Set the maximum token size to 1 MB
)

Variables

Functions

func AppendFileStream

func AppendFileStream(filePath string, destinationFile *os.File) (int64, error)

func DecryptAES

func DecryptAES(src []byte, key, iv []byte) ([]byte, error)

func DeleteDirFile

func DeleteDirFile(fileDir string) error

func DeleteFile

func DeleteFile(file string) error

func DirFileList

func DirFileList(dir string, subDir bool, fullPath bool) ([]string, error)

func Exist

func Exist[T ~int | ~int32 | ~uint32 | ~int64 | ~string](arr []T, n T) bool

func FileEOF

func FileEOF(err error) bool

func FileExist

func FileExist(filePath string) (bool, error)

func FileExt

func FileExt(filePath string) string

func GenApiUUID

func GenApiUUID() string

func GenUUID

func GenUUID() string

func I32

func I32(s string) (int32, error)

func I64

func I64(s string) (int64, error)

func InitTimeLocal

func InitTimeLocal() error

func Int2Str

func Int2Str[T ~int | ~int32 | ~uint32 | ~int64](i T) string

func IsAlphanumeric

func IsAlphanumeric(input string) bool

IsAlphanumeric 特殊字符校验

func LoadConfig

func LoadConfig(in string, cfg interface{}) error

func MD5

func MD5(str []byte) string

func MustI32

func MustI32(s string) int32

func MustI64

func MustI64(s string) int64

func MustU32

func MustU32(s string) uint32

func PrintPanicStack

func PrintPanicStack()

PrintPanicStack recover并打印堆栈 用法:defer util.PrintPanicStack(),注意 defer func() { util.PrintPanicStack() } 是无效的

func PrintPanicStackWithCall

func PrintPanicStackWithCall(postProcessor func(panicOccur bool, recoverError error))

func SHA256

func SHA256(src string) string

func Str2Date

func Str2Date(timeStr string) (int64, error)

func Str2Time

func Str2Time(timeStr string) (int64, error)

func Time2MsStr

func Time2MsStr(millSec int64) string

func Time2Str

func Time2Str(millSec int64) string

func ToFileSizeStr

func ToFileSizeStr(fileSize int64) string

ToFileSizeStr fileSize单位是B,转换规则:小于1M为KB,大于等于1M,单位为M,保留两位小数

func U32

func U32(s string) (uint32, error)

func WeekStartTime

func WeekStartTime(t time.Time, week int) time.Time

WeekStartTime 某周的开始时间(周一0点),-1上周,0本周,1下周

Types

type FileMergeResult

type FileMergeResult struct {
	TotalSuccessCount int64
	TotalLineCount    int64
	TotalByteCount    int64
	FilePath          string
}

func MergeFile

func MergeFile(filePathList []string, mergeFilePath string) (*FileMergeResult, error)

MergeFile 合并文件

Jump to

Keyboard shortcuts

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