common

package
v0.0.0-...-dcafb52 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BeforeDay2Time

func BeforeDay2Time(strDate string) (time.Time, error)

日期转时间 2天前

func BeforeHouse2Time

func BeforeHouse2Time(strDate string) (time.Time, error)

日期转时间 6小时前

func BeforeMinute2Time

func BeforeMinute2Time(strDate string) (time.Time, error)

日期转时间 6分钟前

func CopyFile

func CopyFile(dstName, srcName string) error

复制文件

func CutFile

func CutFile(dstName, srcName string) error

剪切文件

func DateMonth2Time

func DateMonth2Time(strDate string) (time.Time, error)

日期转时间 12月31日

func DateYear2Time

func DateYear2Time(strDate string) (time.Time, error)

日期转时间 2021年12月31日

func FFExec

func FFExec(args ...string) (gjson.Result, error)

调用ffmpeg执行命令并返回结果 依赖ffmpeg

func FormatSubtitleTime

func FormatSubtitleTime(duration float64) string

将时长格式化为字幕时长格式 39.77 >> 00:00:39,770

func FormatTimeStr

func FormatTimeStr(t time.Time) string

格式化事件为标准的字符串

func GetAllFile

func GetAllFile(pathname string, whiteExt ...string) ([]string, error)

遍历文件

func GetFileParam

func GetFileParam(path string, codec_type string) gjson.Result

解析音视频文件参数 依赖 ffprobe

func IsNullOrEmpty

func IsNullOrEmpty(str string) bool

是否空字符

func Isfile

func Isfile(filename string) bool

文件是否存在

func MakePath

func MakePath(filePath string) error

创建文件夹,文件夹如果存在 直接返回

func Md5BufHex

func Md5BufHex(buf []byte) string

获取数据md5的hex编码

func Md5FileHex

func Md5FileHex(filePath string) string

获取文件md5的hex编码

func NewFileLock

func NewFileLock(dir string) *fileLock

func PathExists

func PathExists(path string) (bool, error)

文件文件或文件夹是否存在

func PureFilename

func PureFilename(name string) string

获取纯净文件名 用于保存到磁盘本地

func RandomString

func RandomString(n int, allowedChars ...[]rune) string

生成随机字符串

func RefreshAccessTime

func RefreshAccessTime(filePath string) error

更新文件访问时间为当前时间

func Sha1FileHex

func Sha1FileHex(filePath string) string

file sha1 hex

func Sha1Hex

func Sha1Hex(buf []byte) string

sha1 hex

func SimilarText

func SimilarText(first, second string) float64

计算两个字符串的相似度 0~1.0

func Sm3FileHex

func Sm3FileHex(filePath string) string

file sm3 hex

func Sm3Hex

func Sm3Hex(buf []byte) string

sm3 hex

func Str2Time

func Str2Time(strDate string) time.Time

字符串转时间 处理一些不规则字符串

func TrimAllSpace

func TrimAllSpace(str string) string

删除字符串中的所有空格符

func TrimEnter

func TrimEnter(str string) string

删除换行符

func Unzip

func Unzip(zipFile string, destDir string) error

解压zip文件

func UuidV1

func UuidV1() string

uuidv1

func UuidV4

func UuidV4() string

uuidv4

func Xor

func Xor(data, key []byte) []byte

异或加密

func Yesterday2Time

func Yesterday2Time(strDate string) (time.Time, error)

日期转时间 昨天

func ZipArchive

func ZipArchive(source, target, filter string) error

压缩为zip格式 source为要压缩的文件或文件夹, 绝对路径和相对路径都可以 target是目标文件 filter是过滤正则(Golang 的 包 path.Match)

func ZipArchiveFiles

func ZipArchiveFiles(files map[string]string, target string) error

打包指定的文件集合

Types

type FileStat

type FileStat struct {
	FileInfo os.FileInfo
	// contains filtered or unexported fields
}

文件状态信息

func Stat

func Stat(filePath string) (*FileStat, error)

查询文件状态信息

func (*FileStat) ChangeAccessTime

func (fs *FileStat) ChangeAccessTime(timestamp int64) error

修改文件访问时间

func (*FileStat) GetAccessTime

func (fs *FileStat) GetAccessTime() int64

获取文件的访问时间, 返回时间戳

func (*FileStat) GetCreateTime

func (fs *FileStat) GetCreateTime() int64

获取文件的创建时间, 返回时间戳

func (*FileStat) GetWriteTime

func (fs *FileStat) GetWriteTime() int64

获取文件的修改时间, 返回时间戳

Directories

Path Synopsis
sm
sm3

Jump to

Keyboard shortcuts

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