utils

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2023 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const KEY = "fakeKeyChangeMe!"

KEY 密钥

Variables

This section is empty.

Functions

func AesDecode

func AesDecode(encryptedString string) (string, error)

AesDecode aes解密

使用CFB

func AesEncode

func AesEncode(rawString string) (string, error)

AesEncode aes加密

使用CFB

func Base64Decode

func Base64Decode(encodedString string) ([]byte, error)

Base64Decode base64解码

func Base64Encode

func Base64Encode(rawBytes []byte) string

Base64Encode base64编码

func FileAppendContents

func FileAppendContents(content []byte, dst string) error

FileAppendContents 将内容写入文件(追加写)

content []byte 写入的内容

dst string 写入的目标地址

func FileExists

func FileExists(dst string) bool

FileExists 检查文件上是否存在

dst string 目标地址

func FileExistsWithError

func FileExistsWithError(dst string) (bool, error)

FileExistsWithError 检查文件上是否存在(会返回错误信息)

dst string 目标地址

func FileExt

func FileExt(filename string) string

FileExt 获取文件扩展名

根据文件名最后一个.分隔来切分获取

func FileGetContents

func FileGetContents(filename string) ([]byte, error)

FileGetContents 获取文件内容

filename string 文件地址

func FilePutContents

func FilePutContents(content []byte, dst string) error

FilePutContents 将内容写入文件(覆盖写)

content []byte 写入的内容

dst string 写入的目标地址

func GetLocalIP

func GetLocalIP() (string, error)

func ListeningExitSignal

func ListeningExitSignal(wg *sync.WaitGroup)

ListeningExitSignal 监听系统退出信号

func RSADecrypt

func RSADecrypt(encodedString string, privateKey []byte) (string, error)

RSADecrypt rsa解密

func RSAEncrypt

func RSAEncrypt(rawString string, publicKey []byte) (string, error)

RSAEncrypt rsa加密

func RSASign

func RSASign(rawStringBytes, privateKey []byte) (string, error)

RSASign rsa加签

func RSAVerifySign

func RSAVerifySign(rawStringBytes, sign, publicKey []byte) (bool, error)

RSAVerifySign rsa验签

func RandomDigitalChars

func RandomDigitalChars(length int) string

RandomDigitalChars 随机字符串(数字)

func RandomLetters

func RandomLetters(length int) string

RandomLetters 随机字符串(字母)

func SaveFile2Dst

func SaveFile2Dst(file *multipart.FileHeader, dst string) error

SaveFile2Dst 将文件保存到目标地址(拷贝文件)

file *multipart.FileHeader 文件

dst string 拷贝到的目标地址

func Wordwrap

func Wordwrap(rawStr string, length int, split string) string

Wordwrap 以给定的字符和长度来打断字符串

func WrapRedisKey

func WrapRedisKey(appName, key string) string

WrapRedisKey 包装redis键名

给redis的键加入应用名前缀,如:

appName=game key=user

最终的redis键名为:game:user

此方法的主要作用是按应用来划分redis键名

Types

type TIM

type TIM struct {
	// contains filtered or unexported fields
}

func NewTimeWithTimeZone

func NewTimeWithTimeZone(timeZone ...string) *TIM

NewTimeWithTimeZone 根据时区初始化时间

默认时区: Asia/Shanghai

func (*TIM) Datetime

func (t *TIM) Datetime() string

func (*TIM) Now

func (t *TIM) Now() time.Time

Jump to

Keyboard shortcuts

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