go_utils

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2021 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

* @Author: i@douxuefeng.cn * @Date: 2021-10-23 13:44:03 * @LastEditTime: 2021-10-29 19:21:04 * @LastEditors: i@douxuefeng.cn * @Description: 加密算法 * @FilePath: \go-utils\string_encript.go

Index

Constants

This section is empty.

Variables

View Source
var (
	Validate      *validator.Validate
	ValidateTrans ut.Translator
)

表单验证 https://github.com/go-playground/validator

View Source
var NewFile = newFile()
View Source
var SnowFlake *snowflake.Node

Functions

func AesDecrypt added in v0.0.2

func AesDecrypt(encrypted, cip string) (string, error)

*

  • @name: ase 解密
  • @description:
  • @param {*} encrypted 加密字符串
  • @param {string} cip 密文
  • @return {*}

func AesEncrypt added in v0.0.2

func AesEncrypt(origin, cip string) (string, error)

*

  • @name: AES加密 cbc
  • @description:
  • @param {*} origin 需要加密的字符串
  • @param {string} cip 密文
  • @return {*}

func Base64Decoding

func Base64Decoding(s string) string

func Base64Encoding

func Base64Encoding(s string) string

base64 加密

func EncodePassword

func EncodePassword(password string) string

func GetRandomNumber

func GetRandomNumber(l int) string

随机生成数字字符串

func GetRandomPureString

func GetRandomPureString(l int) string

随机生成纯字符串

func GetRandomString

func GetRandomString(l int) string

随机生成字符串

func InitSnowflake

func InitSnowflake(epoch int64, i int64)

func JoinStringArr

func JoinStringArr(strs, str string, dep string) string

*

  • @name: 向字符串增加字符
  • @description:
  • @param {*} strs 使用dep隔开的字符串
  • @param {string} str 需要添加的字符串
  • @param {string} dep
  • @return {*}

func Md5

func Md5(s string) string

func Padding added in v0.0.2

func Padding(plaintext []byte, blockSize int) []byte

func Sha1

func Sha1(s string) string

func UnPadding added in v0.0.2

func UnPadding(origData []byte) []byte

func Uuid

func Uuid() string

func ValidatePassword

func ValidatePassword(encodePassword, inputPassword string) bool

func ValidateStruct

func ValidateStruct(s interface{}) error

Types

type File

type File struct {
}

func (*File) AppendFile

func (f *File) AppendFile(filename string, data []byte) error

向文件追加内容

func (*File) CreateFile

func (f *File) CreateFile(filePath string) error

调用os.MkdirAll递归创建文件夹

func (*File) IsExist

func (f *File) IsExist(path string) bool

判断所给路径文件/文件夹是否存在(返回true是存在)

func (*File) WriteFile

func (f *File) WriteFile(filename string, data []byte, perm os.FileMode) error

将数据写入文件中,如果文件已存在,覆盖

type JsonData

type JsonData struct {
	Code int         `json:"code"`
	Data interface{} `json:"data"`
	Msg  string      `json:"msg"`
}

func Json

func Json(code int, data interface{}, msg string) *JsonData

func JsonErr

func JsonErr(code int, err error) *JsonData

func JsonNoData

func JsonNoData(code int, msg string) *JsonData

func Response

func Response(code int, err error, msg string, data interface{}) *JsonData

type Page

type Page struct {
	Total       int64       `json:"total"`
	CurrentPage int         `json:"current_page"`
	PerPage     int         `json:"per_page"`
	LastPage    int         `json:"last_page"`
	Data        interface{} `json:"data"`
}

func NewPage

func NewPage(total int64, currentPage, perPage int, data interface{}) *Page

Directories

Path Synopsis
* Desc: * Package: cache * File Created: Sunday, 21st March 2021 4:04:59 pm * Author: douxuefeng (i@douxuefeng.cn) * ----- * Last Modified: Sunday, 21st March 2021 4:04:59 pm * Modified By: douxuefeng (i@douxuefeng.cn>) * Desc: * Package: cache * File Created: Sunday, 21st March 2021 3:55:50 pm * Author: douxuefeng (i@douxuefeng.cn) * ----- * Last Modified: Sunday, 21st March 2021 3:55:50 pm * Modified By: douxuefeng (i@douxuefeng.cn>)
* Desc: * Package: cache * File Created: Sunday, 21st March 2021 4:04:59 pm * Author: douxuefeng (i@douxuefeng.cn) * ----- * Last Modified: Sunday, 21st March 2021 4:04:59 pm * Modified By: douxuefeng (i@douxuefeng.cn>) * Desc: * Package: cache * File Created: Sunday, 21st March 2021 3:55:50 pm * Author: douxuefeng (i@douxuefeng.cn) * ----- * Last Modified: Sunday, 21st March 2021 3:55:50 pm * Modified By: douxuefeng (i@douxuefeng.cn>)
sms
aliyun_sms
* @Author: i@douxuefeng.cn * @Date: 2021-10-13 13:38:48 * @LastEditTime: 2021-10-13 14:05:19 * @LastEditors: i@douxuefeng.cn * @Description: * @FilePath: \go-utils\sms\aliyun_sms\aliyun.go
* @Author: i@douxuefeng.cn * @Date: 2021-10-13 13:38:48 * @LastEditTime: 2021-10-13 14:05:19 * @LastEditors: i@douxuefeng.cn * @Description: * @FilePath: \go-utils\sms\aliyun_sms\aliyun.go
wechat
mp/params
* Desc: * Package: params * File Created: Friday, 26th March 2021 8:45:18 am * Author: douxuefeng (i@douxuefeng.cn) * ----- * Last Modified: Friday, 26th March 2021 8:45:18 am * Modified By: douxuefeng (i@douxuefeng.cn>) * Desc: * Package: params * File Created: Saturday, 27th March 2021 9:35:31 pm * Author: douxuefeng (i@douxuefeng.cn) * ----- * Last Modified: Saturday, 27th March 2021 9:35:31 pm * Modified By: douxuefeng (i@douxuefeng.cn>) * @Author: i@douxuefeng.cn * @Date: 2021-10-25 16:15:38 * @LastEditTime: 2021-10-29 10:57:32 * @LastEditors: i@douxuefeng.cn * @Description: * @FilePath: \go-utils\wechat\mp\params\sns.go
* Desc: * Package: params * File Created: Friday, 26th March 2021 8:45:18 am * Author: douxuefeng (i@douxuefeng.cn) * ----- * Last Modified: Friday, 26th March 2021 8:45:18 am * Modified By: douxuefeng (i@douxuefeng.cn>) * Desc: * Package: params * File Created: Saturday, 27th March 2021 9:35:31 pm * Author: douxuefeng (i@douxuefeng.cn) * ----- * Last Modified: Saturday, 27th March 2021 9:35:31 pm * Modified By: douxuefeng (i@douxuefeng.cn>) * @Author: i@douxuefeng.cn * @Date: 2021-10-25 16:15:38 * @LastEditTime: 2021-10-29 10:57:32 * @LastEditors: i@douxuefeng.cn * @Description: * @FilePath: \go-utils\wechat\mp\params\sns.go

Jump to

Keyboard shortcuts

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