util

package
v1.4.5 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2020 License: MIT Imports: 15 Imported by: 2

README

工具函数

godoc

API 文档

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AesDecrypt

func AesDecrypt(src []byte, key []byte) []byte

func AesEncrypt

func AesEncrypt(src, key []byte) ([]byte, error)

func Assert

func Assert(err error, msg interface{})

Assert 断言 err != nil

func AssignMap

func AssignMap(maps ...map[interface{}]interface{}) map[interface{}]interface{}

AssignMap 合并多个map

func Base64Decoding

func Base64Decoding(enc string) (string, error)

Base64Decoding base64 解码

func Base64Encoding

func Base64Encoding(str string) string

Base64Encoding base64 编码

func BcryptHash

func BcryptHash(src string) string

func BcryptVerify

func BcryptVerify(hash, src string) bool

func ByteToReadCloser

func ByteToReadCloser(b []byte) io.ReadCloser

ByteToReadCloser 将字节转换成一次性的读取流

func ByteToReader

func ByteToReader(b []byte) io.Reader

ByteToReader 将字节转换成读取流

func BytesCombine

func BytesCombine(pBytes ...[]byte) []byte

func FuncName

func FuncName(f interface{}) string

FuncName 获取函数的名字

func HasFile

func HasFile(f string) bool

HasFile 是否存在该文件

func RandomStr

func RandomStr(length int) string

RandomStr 生成随机字符串

func StructToMap

func StructToMap(v interface{}) map[string]interface{}

StructToMap 把结构体转成map,key使用json定义的key

func ToString

func ToString(v interface{}) string

ToString 把能转成字符串的都转成JSON字符串

func ToStruct

func ToStruct(raw interface{}, v interface{}) error

ToStruct 把一个结构体转成另一个结构体,以json key作为关联

func XID

func XID() string

XID 生成一个全局唯一的 id 字符串 实际上是改造后的 uuid.v4

Types

type ErrorData added in v1.2.16

type ErrorData struct {
	Code   int         `json:"-"` // http 状态码
	Status int         `json:"status"`
	Msg    string      `json:"msg"`
	Data   interface{} `json:"data"`
}

func ParseError added in v1.2.16

func ParseError(v interface{}) *ErrorData

parse 解析响应数据

Jump to

Keyboard shortcuts

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