gotil

package module
v1.0.14 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2020 License: Apache-2.0 Imports: 13 Imported by: 5

README

go-util

项目 common 库

Golang GoDoc Drone CI GitHub Release License

Install
go get github.com/housemecn/gotil
目录结构
.
├── LICENSE
├── README.md
├── aes
│   ├── aes_cbc_decrypt.go
│   ├── aes_cbc_encrypt.go
│   └── pkcs_padding.go
├── body_map.go
├── constants.go
├── convert.go
├── ecode
│   ├── common.go
│   └── ecode.go
├── errgroup
│   └── errgroup.go
├── go.mod
├── go.sum
├── lru
│   ├── cache.go
│   └── cache_test.go
├── proxy
│   ├── http.go
│   ├── model.go
│   ├── proxy_test.go
│   └── service.go
├── random.go
├── rate
│   └── rate.go
├── retry
│   ├── retry.go
│   └── retry_test.go
├── slice.go
├── string.go
├── verify.go
├── ws
│   └── websocket_connection.go
├── xhttp
│   ├── client.go
│   ├── client_test.go
│   └── model.go
├── xlog
│   ├── debug_logger.go
│   ├── error_logger.go
│   ├── info_logger.go
│   ├── log.go
│   ├── log_test.go
│   ├── warn_logger.go
│   └── zap.go
├── xrsa
│   ├── rsa_decrypt.go
│   └── rsa_encrypt.go
└── xtime
    ├── parse_format.go
    └── xtime.go

Documentation

Index

Constants

View Source
const (
	TimeLayout   = "2006-01-02 15:04:05"
	TimeLayout_1 = "2006-01-02 15:04:05.000"
	TimeLayout_2 = "20060102150405"
	DateLayout   = "2006-01-02"
	NULL         = ""
)

Variables

This section is empty.

Functions

func BinaryToDecimal

func BinaryToDecimal(bit string) (num int)

二进制转10进制

func Float32ToString

func Float32ToString(floatNum float32, prec ...int) (floatStr string)

Float32转字符串

floatNum:float32数字
prec:精度位数(不传则默认float数字精度)

func Float64ToString

func Float64ToString(floatNum float64, prec ...int) (floatStr string)

Float64转字符串

floatNum:float64数字
prec:精度位数(不传则默认float数字精度)

func GetRandomNumber

func GetRandomNumber(l int) string

随机生成数字字符串

func GetRandomPureString

func GetRandomPureString(l int) string

随机生成纯字符串

func GetRandomString

func GetRandomString(l int) string

随机生成字符串

func Int2String

func Int2String(intNum int) (intStr string)

Int转字符串

intNum:数字字符串

func Int642String

func Int642String(intNum int64) (int64Str string)

Int64转字符串

intNum:数字字符串

func JoinInts

func JoinInts(is []int64) string

JoinInts format int64 slice like:n1,n2,n3.

func MergeSliceRemoveDuplicate

func MergeSliceRemoveDuplicate(slice1, slice2 []int) (merged []int)

int数组合并,去重复

func SplitInts

func SplitInts(s string) ([]int64, error)

SplitInts split string into int64 slice.

func String2Float32

func String2Float32(floatStr string) (floatNum float32)

字符串转Float32

floatStr:小数点数字的字符串

func String2Float64

func String2Float64(floatStr string) (floatNum float64)

字符串转Float64

floatStr:小数点数字的字符串

func String2Int

func String2Int(intStr string) (intNum int)

字符串转Int

intStr:数字的字符串

func String2Int64

func String2Int64(intStr string) (int64Num int64)

字符串转Int64

intStr:数字的字符串

func VerifyIDCard

func VerifyIDCard(idCard string) bool

计算规则参考“中国国家标准化管理委员会”官方文档:http://www.gb688.cn/bzgk/gb/newGbInfo?hcno=080D6FBF2BB468F9007657F26D60013E 身份证号码校验

func VerifyPhoneNumber

func VerifyPhoneNumber(phone string) bool

手机号码校验

Types

type BodyMap

type BodyMap map[string]interface{}

func (BodyMap) CheckEmptyError

func (bm BodyMap) CheckEmptyError(keys ...string) error

func (BodyMap) EncodeAliPaySignParams

func (bm BodyMap) EncodeAliPaySignParams() string

("bar=baz&foo=quux") sorted by key.

func (BodyMap) EncodeGetParams

func (bm BodyMap) EncodeGetParams() string

func (BodyMap) EncodeSortParams

func (bm BodyMap) EncodeSortParams() string

("bar=baz&foo=quux") sorted by key.

func (BodyMap) EncodeWeChatSignParams

func (bm BodyMap) EncodeWeChatSignParams(apiKey string) string

("bar=baz&foo=quux") sorted by key.

func (BodyMap) Get

func (bm BodyMap) Get(key string) string

获取参数

func (BodyMap) MarshalXML

func (bm BodyMap) MarshalXML(e *xml.Encoder, start xml.StartElement) (err error)

func (BodyMap) Remove

func (bm BodyMap) Remove(key string)

删除参数

func (BodyMap) Set

func (bm BodyMap) Set(key string, value interface{})

设置参数

func (*BodyMap) UnmarshalXML

func (bm *BodyMap) UnmarshalXML(d *xml.Decoder, start xml.StartElement) (err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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