util

package
v0.0.0-...-3b8c608 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2021 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AesDecrypt

func AesDecrypt(crypted, key []byte) ([]byte, error)

func AesEncrypt

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

func Base64Decode

func Base64Decode(sourceStr string) (string, error)

func Base64Encode

func Base64Encode(sourceStr string) string

func GenNonceStr

func GenNonceStr() string

生成噪声字符串(复用uuid)

func GenShortUuid

func GenShortUuid() string

func GenTransId

func GenTransId() string

生成交易ID

func GenUuid

func GenUuid() string

生成uuid

func GetBetweenStr

func GetBetweenStr(str, start, end string) string

获取两个字符串中间的字符串

func GetTLSConfig

func GetTLSConfig(certPath, keyPath string) (*tls.Config, error)

func GetWxTime

func GetWxTime(timestamp ...int) string

把时间戳转换成微信支付要求的时间格式:20060102030405

func HttpGet

func HttpGet(url string) (string, error)

func HttpGetOriginData

func HttpGetOriginData(getUrl string) (body []byte)

func HttpPost

func HttpPost(url string, data string) (string, error)

data => aaa=data&bbb=data

func HttpPostWithSignHeader

func HttpPostWithSignHeader(url string, data string, sign string) (string, error)

func IsEmpty

func IsEmpty(value interface{}) bool

func IsLiveMode

func IsLiveMode() bool

判断是不是正式模式

func Json2Map

func Json2Map(jsonStr string) (s map[string]interface{}, err error)

func JsonDecode

func JsonDecode(jsonStr string, structModel interface{}) error

func JsonEncode

func JsonEncode(structModel interface{}) (string, error)

func MapKeyFirstToLower

func MapKeyFirstToLower(data map[string]interface{}) (retData map[string]interface{})

map的key周字符小写

func Md5

func Md5(str string) string

func PKCS7Padding

func PKCS7Padding(ciphertext []byte, blockSize int) []byte

func PKCS7UnPadding

func PKCS7UnPadding(origData []byte) []byte

func Rand

func Rand() float64

生成随机数

func RandWithMax

func RandWithMax(maxNum int) int32

func SecurePost

func SecurePost(url string, data string, certPath string, keyPath string) (string, error)

func StrFirstToUpper

func StrFirstToUpper(str string) string

字符串首字母大写

func StringSliceUnique

func StringSliceUnique(slc []string) []string

字符串数组去重

func Struct2Map

func Struct2Map(obj interface{}) (data map[string]interface{}, err error)

结构体转map,tag: `data:"aliasName;required"`

func SubString

func SubString(str string, begin, length int) (substr string)

字符串分割

func TimeStr2Time

func TimeStr2Time(timeStr, format string) int

func Timestamp

func Timestamp() int

func VerifyIdCard

func VerifyIdCard(idCard string) bool

校验身份证规则合法性

func WxTimeStr2Timestamp

func WxTimeStr2Timestamp(timeStr string) int

func XmlDecode

func XmlDecode(xmlStr string) (map[string]interface{}, error)

func XmlEncode

func XmlEncode(xmlMap map[string]interface{}) (string, error)

Types

type XmlCDATA

type XmlCDATA struct {
	Text string `xml:",cdata"`
}

Jump to

Keyboard shortcuts

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