gotil

package module
v1.0.4-beta1 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

README

go-util

自己整理的一些常用工具类合集

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func BinaryToDecimal added in v1.0.1

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 added in v1.0.2

func JoinInts(is []int64) string

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

func MergeSliceRemoveDuplicate added in v1.0.2

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

int数组合并,去重复

func SplitInts added in v1.0.2

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 added in v1.0.2

func VerifyIDCard(idCard string) bool

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

func VerifyPhoneNumber added in v1.0.2

func VerifyPhoneNumber(phone string) bool

手机号码校验

Types

type BodyMap added in v1.0.2

type BodyMap map[string]interface{}

func (BodyMap) CheckEmptyError added in v1.0.2

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

func (BodyMap) EncodeAliPaySignParams added in v1.0.2

func (bm BodyMap) EncodeAliPaySignParams() string

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

func (BodyMap) EncodeGetParams added in v1.0.2

func (bm BodyMap) EncodeGetParams() string

func (BodyMap) EncodeSortParams added in v1.0.4

func (bm BodyMap) EncodeSortParams() string

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

func (BodyMap) EncodeWeChatSignParams added in v1.0.2

func (bm BodyMap) EncodeWeChatSignParams(apiKey string) string

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

func (BodyMap) Get added in v1.0.2

func (bm BodyMap) Get(key string) string

获取参数

func (BodyMap) MarshalXML added in v1.0.2

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

func (BodyMap) Remove added in v1.0.2

func (bm BodyMap) Remove(key string)

删除参数

func (BodyMap) Set added in v1.0.2

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

设置参数

func (*BodyMap) UnmarshalXML added in v1.0.2

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