utils

package
v1.5.17 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2023 License: Apache-2.0 Imports: 26 Imported by: 20

Documentation

Index

Constants

This section is empty.

Variables

View Source
var API_ROOT string

当前项目根目录

View Source
var DisableCache bool

DisableCache will disable caching of the home directory. Caching is enabled by default.

Functions

func CheckFileIsExist added in v1.1.0

func CheckFileIsExist(filename string) bool

*

  • 判断文件是否存在 存在返回 true 不存在返回false

func DeCompress added in v1.1.0

func DeCompress(zipFile, dest string) error

解压

func DeleteFile added in v1.1.0

func DeleteFile(filePath string) error

func Dir

func Dir() (string, error)

Dir returns the home directory for the executing user.

This uses an OS-specific method for discovering the home directory. An error is returned if a home directory cannot be detected.

func Expand

func Expand(path string) (string, error)

Expand expands the path to include the home directory if the path is prefixed with `~`. If it isn't prefixed with `~`, the path is returned as-is.

func GetDate

func GetDate() string

返回当前时间

func GetFileSize added in v1.1.0

func GetFileSize(filePath string) (int64, error)

func GetMD5

func GetMD5(plainText string) string

MD5 加密字符串

func GetMd5 added in v1.1.0

func GetMd5(path string) (string, error)

计算文件的md5,适用于本地文件计算

func GetMd52 added in v1.1.0

func GetMd52(file io.Reader) (io.Reader, string, error)

从流中直接读取数据计算md5 并返回流的副本,不能用于计算大文件流否则内存占用很大 @return io.Reader @params file的副本

func GetParamHmacMD5Sign

func GetParamHmacMD5Sign(secret, params string) (string, error)

func GetParamHmacSHA1Sign

func GetParamHmacSHA1Sign(secret, params string) (string, error)

func GetParamHmacSHA256Base64Sign

func GetParamHmacSHA256Base64Sign(secret, params string) (string, error)

func GetParamHmacSHA256Sign

func GetParamHmacSHA256Sign(secret, params string) (string, error)

func GetParamHmacSHA512Base64Sign

func GetParamHmacSHA512Base64Sign(hmac_key string, hmac_data string) string

func GetParamHmacSHA512Sign

func GetParamHmacSHA512Sign(secret, params string) (string, error)

func GetParamHmacSha384Sign

func GetParamHmacSha384Sign(secret, params string) (string, error)

for bitfinex.com

func GetParamMD5Sign

func GetParamMD5Sign(secret, params string) (string, error)

*

*md5签名,okcoin和huobi适用

func GetPath

func GetPath() string

获取项目路径

func GetRandomNumeral

func GetRandomNumeral(l int) string

func GetRandomString

func GetRandomString(l int) string

func GetRunTime

func GetRunTime() string

获取当前系统环境

func GetSHA

func GetSHA(text string) (string, error)

func GzipDecode

func GzipDecode(msg string) string

func GzipEncode

func GzipEncode(msg string) string

func IsDirExists

func IsDirExists(path string) bool

判断文件目录否存在

func MkDir added in v1.1.0

func MkDir(path string) error

创建文件夹,支持x/a/a 多层级

func MkdirFile

func MkdirFile(path string) error

创建文件

func RandInt

func RandInt(min int, max int) int

随机数

func RandInt64

func RandInt64(min int64, max int64) int64

func UploadFile added in v1.1.0

func UploadFile(file *multipart.FileHeader, path string) (string, error)

func UrlDecode

func UrlDecode(urls string) (string, error)

URL解码

func UrlEncode

func UrlEncode(urls string) (string, error)

URL编码

Types

This section is empty.

Jump to

Keyboard shortcuts

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