function

package
v1.3.9 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2023 License: Apache-2.0 Imports: 35 Imported by: 0

README

一、Base编码

1、base64

26个小写字母、26个大写字母、10个数字、/、+

2、base58(区块链)

去掉6个容易混淆的,去掉0,大写的O、大写的I、小写的L、/、+/、+影响双击选择

3、base58编码表

image

4、base58的编码过程

image

  • 将字符串的每个字节换算成ASCII,字符串实际上就是256进制的数字组合
  • 将256进制的数字转换成10进制数字
  • 将10进制数字转换成58进制数字(除以58,每次得到的余数就是对应的58进制,0用编码1来代表)
  • 将58进制数字对照58编码表找到对应的字符

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TimeLayoutYMDHIS string = "20060102150405"
	TimeLayout       string = "2006-01-02 15:04:05"
	TimeLayoutYMD    string = "2006-01-02"
	TimeLayoutYM     string = "2006-01"
)
View Source
var TimeVariable int64

TimeVariable 时间变量[有可能是正负数]

Functions

func AfterDayTime added in v0.1.3

func AfterDayTime(days ...int) time.Time

AfterDayTime N天后的当前时间

func AfterDayTimePlus added in v1.3.6

func AfterDayTimePlus(days int, ts ...time.Time) time.Time

AfterDayTimePlus N天后的当前时间

func AfterMonthTime added in v0.5.0

func AfterMonthTime(months ...int) time.Time

AfterMonthTime N月后的当前时间

func AfterSecondTime added in v0.7.0

func AfterSecondTime(seconds ...int64) time.Time

AfterSecondTime N秒后的时间

func AfterYearTime added in v0.7.0

func AfterYearTime(years ...int) time.Time

AfterYearTime N年后的当前时间

func Base58Decode added in v0.8.5

func Base58Decode(str string) string

Base58Decode base58_decode

func Base58Encode added in v0.8.5

func Base58Encode(str string) string

Base58Encode base58_encode

func Base64Decode added in v0.5.5

func Base64Decode(str string) string

Base64Decode base64_decode

func Base64Encode added in v0.5.5

func Base64Encode(str string) string

Base64Encode base64_encode

func BeforeDayTime added in v0.0.17

func BeforeDayTime(days ...int) time.Time

BeforeDayTime N天前的当前时间

func BeforeMonthTime added in v0.5.0

func BeforeMonthTime(months ...int) time.Time

BeforeMonthTime N月前的当前时间

func BeforeSecondTime added in v0.7.0

func BeforeSecondTime(seconds ...int64) time.Time

BeforeSecondTime N秒前的时间

func BeforeYearTime added in v0.7.0

func BeforeYearTime(years ...int) time.Time

BeforeYearTime N年前的当前时间

func Ceil added in v1.3.7

func Ceil(f64 float64, n ...int) float64

Ceil 向下取值/整[n为保留的小数点位数]

func CheckCompanyCodeRule added in v1.2.7

func CheckCompanyCodeRule(companyCode string) bool

CheckCompanyCodeRule 校验统一社会信用代码

func CheckEmailRule added in v0.0.2

func CheckEmailRule(email string) bool

CheckEmailRule 验证电子邮箱

func CheckIdCardFrontAndBackInfoIsFit added in v0.11.2

func CheckIdCardFrontAndBackInfoIsFit(address, organization string, seps ...string) bool

CheckIdCardFrontAndBackInfoIsFit 判断身份证住址和签发机关是否一致

func CheckIdNumRule added in v0.0.2

func CheckIdNumRule(idNum string) bool

CheckIdNumRule 验证身份证号码的合法性

func CheckIdNumRuleSimple added in v0.0.19

func CheckIdNumRuleSimple(idNum string) bool

CheckIdNumRuleSimple 简单校验身份证号码的位数+组成字符

func CheckMobileNumRule added in v0.0.2

func CheckMobileNumRule(mobile string) bool

CheckMobileNumRule 验证手机号码

func CheckStringLength added in v0.0.14

func CheckStringLength(str string, length int) bool

CheckStringLength 判断字符串长度是否在规定范围内

func CheckUrlRule added in v1.3.2

func CheckUrlRule(url string) bool

CheckUrlRule 校验URL

func CheckWeChatOpenId added in v0.12.4

func CheckWeChatOpenId(openId string) bool

CheckWeChatOpenId 验证微信公众号和小程序的OpenID

func CheckWeChatUnionId added in v1.2.3

func CheckWeChatUnionId(unionId string) bool

CheckWeChatUnionId 验证微信公众号和小程序的UnionID

func ChineseToUnicode added in v0.12.5

func ChineseToUnicode(str string) string

ChineseToUnicode 中文转Unicode

func CleanTime added in v1.1.11

func CleanTime()

CleanTime 清理指定的时间并校准为服务器的时间

func CreateFraction added in v1.1.2

func CreateFraction(f64 float64, n int) float64

CreateFraction 创建分数[n为保留的小数点位数]

func CreateOrderNo added in v0.1.0

func CreateOrderNo() (sn string)

CreateOrderNo 生成平台32位订单号 [不推荐使用]

func DayStartAndEndTime added in v0.7.3

func DayStartAndEndTime(ts ...time.Time) (startTime, endTime time.Time)

DayStartAndEndTime 该天00:00:00时间和该天23:59:59时间

func DayToTime added in v1.2.0

func DayToTime(day int8, hour, minute, second int8, ts ...time.Time) (t time.Time, err error)

DayToTime 根据天数/号返回指定 Time

func DownInteger added in v0.4.2

func DownInteger(f float64) float64

DownInteger 向下取整

func DownIntegerToInt64 added in v0.4.4

func DownIntegerToInt64(f float64) int64

DownIntegerToInt64 向下取整返回int64

func EarthDistance added in v0.3.2

func EarthDistance(lat1, lng1, lat2, lng2 float64, units ...string) float64

EarthDistance 两点之间的距离,不分前后[默认单位:米]

func FebruaryIsLeapYear added in v1.1.13

func FebruaryIsLeapYear(year int) bool

FebruaryIsLeapYear 二月是否是闰年

func FenToYuanToString added in v1.3.5

func FenToYuanToString(f int64) string

FenToYuanToString 人民币分转元字符串类型

func FileExists added in v0.6.5

func FileExists(path string) bool

FileExists 判断文件或目录是否存在

func FileGetContents added in v0.5.3

func FileGetContents(filename string) (str string, err error)

FileGetContents 把整个文件读入一个字符串中

func FilePutContentToAppend added in v0.5.6

func FilePutContentToAppend(filename string, data string) (err error)

FilePutContentToAppend 把一个字符串写入文件中[追加至原文件]

func FilePutContents added in v0.5.3

func FilePutContents(filename string, data string) error

FilePutContents 把一个字符串写入文件中[覆盖原文件内容]

func Float32ToString added in v0.0.2

func Float32ToString(f float64) string

Float32ToString float32转string

func Float64MulFloat64 added in v1.1.5

func Float64MulFloat64(f1, f2 float64) (res float64, exact bool)

Float64MulFloat64 float64 * float64

func Float64MulInt64 added in v1.1.5

func Float64MulInt64(f float64, i int64) (res float64, exact bool)

Float64MulInt64 float64 * int64

func Float64ToInt64 added in v0.2.9

func Float64ToInt64(f float64) int64

Float64ToInt64 float64转int64

func Float64ToString added in v0.0.2

func Float64ToString(f float64) string

Float64ToString float64转string

func FloatRound added in v0.2.2

func FloatRound(f float64, n int) (res float64, err error)

FloatRound 四舍五入 [n为保留的小数点位数] [不优先使用]

func GenerateOrderNo added in v0.4.0

func GenerateOrderNo() string

GenerateOrderNo 生成24位订单号 [前面17位代表时间精确到毫秒,中间3位代表进程id,最后4位代表序号]

func GetBetweenDays added in v0.7.0

func GetBetweenDays(startDate, endDate string, layouts ...string) (d []string)

GetBetweenDays 根据开始日期和结束日期计算出时间段内所有日期[两个日期内所有天数]

func GetBetweenMonths added in v0.4.5

func GetBetweenMonths(startDate, endDate string, layouts ...string) (d []string)

GetBetweenMonths 根据开始日期和结束日期计算出时间段内所有月份

func GetFirstAndEndString added in v0.11.8

func GetFirstAndEndString(str string) (string, string)

GetFirstAndEndString 获取第一个和最后一个字符串[不区分中英文]

func GetStringPointer added in v0.13.2

func GetStringPointer(str string) *string

GetStringPointer 返回字符串类型的指针

func GetStringPointerValue added in v0.13.2

func GetStringPointerValue(str *string) string

GetStringPointerValue 返回字符串指针类型的值

func HashFile added in v0.10.0

func HashFile(path string) (string, error)

HashFile 文件哈希[优先使用]

func HashFileToMd5 added in v0.10.0

func HashFileToMd5(path string) (string, error)

HashFileToMd5 文件哈希[MD5]

func HashHmac added in v0.9.4

func HashHmac(algo, msg, key string) string

HashHmac 使用HMAC方法生成键控哈希值[hash_hmac]

func IdCardBirthHandle added in v0.6.2

func IdCardBirthHandle(birth string, layouts ...string) (time.Time, error)

IdCardBirthHandle 身份证出生日期处理,统一格式:[2020年1月1日]

func IdCardDeadlineHandle added in v0.6.5

func IdCardDeadlineHandle(date string, layouts ...string) (starTime, endTime time.Time, err error)

IdCardDeadlineHandle 身份证有效期处理,统一格式:[2018.08.01-2028.08.01]

func Idx added in v1.3.0

func Idx(str string) string

Idx 索引

func InSlice added in v0.2.6

func InSlice(slice []string, target string) bool

InSlice 判断切片中是否存在某值

func Int64LengthPadding added in v0.11.4

func Int64LengthPadding(i64 int64, length int) string

Int64LengthPadding 数字长度不够左侧填补0并返回字符串

func Int64ToFloat64 added in v0.2.9

func Int64ToFloat64(i64 int64) float64

Int64ToFloat64 int64转float64

func Int64ToInt added in v0.0.2

func Int64ToInt(i64 int64) int

Int64ToInt int64转int

func Int64ToString added in v0.0.2

func Int64ToString(i64 int64) string

Int64ToString int64转string

func IntToInt64 added in v0.3.0

func IntToInt64(i int) int64

IntToInt64 int转int64

func InterceptDecimal added in v0.2.2

func InterceptDecimal(f float64, n int) float64

InterceptDecimal 不四舍五入截取小数点 [n为保留的小数点数位数]

func InterceptDecimalToString added in v0.2.5

func InterceptDecimalToString(f float64, n int) string

InterceptDecimalToString 不四舍五入截取小数点后为字符串格式 [n为保留的小数点数位数]

func IsCCBCardNo added in v0.9.12

func IsCCBCardNo(cardNo string) bool

IsCCBCardNo 是否为建设银行卡号 [2020.09.30新增62153403][2019.11.28新增621673][普通高中学生资助卡:623094]

func IsChinese added in v0.6.2

func IsChinese(str string) bool

IsChinese 是否全部为中文

func IsDir added in v0.6.5

func IsDir(path string) bool

IsDir 判断所给路径是否为文件夹

func IsFile added in v0.6.5

func IsFile(path string) bool

IsFile 判断所给路径是否为文件

func JsonEncode added in v0.9.1

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

JsonEncode json_encode

func LcFirst added in v0.6.6

func LcFirst(str string) string

LcFirst 仅开头字母小写[将字符串中的第一个字母转换成小写]

func LcWords added in v0.6.6

func LcWords(str string) (res string)

LcWords 所有首字母小写[将字符串中每个单词的首字母转换成小写]

func MapMerge added in v0.4.3

func MapMerge(m1, m2 map[string]string, trimEmpties ...bool) (m map[string]string)

MapMerge 两个MAP合并,两个MAP键相同的情况,后面MAP的值覆盖前面MAP的值

func Md5 added in v0.0.2

func Md5(str string) string

Md5 md5加密

func Md516 added in v0.3.8

func Md516(str string) string

Md516 返回16位MD5加密字符串

func MonthDays added in v1.1.13

func MonthDays(ts ...time.Time) int8

MonthDays 该月有多少天

func MonthStartAndEndTime added in v0.7.3

func MonthStartAndEndTime(ts ...time.Time) (startTime, endTime time.Time)

MonthStartAndEndTime 该月1号00:00:00时间和该月末23:59:59时间

func MoreFloat64Mul added in v1.1.6

func MoreFloat64Mul(fn ...float64) (res float64, exact bool)

MoreFloat64Mul 多个Float64相乘

func NewTime added in v1.1.11

func NewTime(timeStr string, layouts ...string) (err error)

NewTime 创建一个全局指定的 Time

func NowMonthStartAndEndTime added in v0.7.0

func NowMonthStartAndEndTime() (startTime, endTime time.Time)

NowMonthStartAndEndTime 本月1号00:00:00时间和本月末23:59:59时间

func NowQuarterStartAndEndTime added in v0.7.0

func NowQuarterStartAndEndTime() (startTime, endTime time.Time)

NowQuarterStartAndEndTime 本季度1号00:00:00时间和本季度末23:59:59时间

func NowWeekStartAndEndTime added in v0.7.0

func NowWeekStartAndEndTime() (startTime, endTime time.Time)

NowWeekStartAndEndTime 本周一00:00:00时间和本周日23:59:59时间

func NowYearStartAndEndTime added in v0.7.0

func NowYearStartAndEndTime() (startTime, endTime time.Time)

NowYearStartAndEndTime 本年1月1号00:00:00时间和本年12月31号23:59:59时间

func OneYearCycleMonthRange added in v1.3.8

func OneYearCycleMonthRange(start int) (list []int)

OneYearCycleMonthRange 一年周期月范围

func OrderNoStrDecode added in v1.2.4

func OrderNoStrDecode(str string) string

func OrderNoStrEncode added in v1.2.4

func OrderNoStrEncode(str string) string

func QuarterStartAndEndTime added in v0.7.3

func QuarterStartAndEndTime(ts ...time.Time) (startTime, endTime time.Time)

QuarterStartAndEndTime 该季度1号00:00:00时间和该季度末23:59:59时间

func RandFixedString added in v0.11.5

func RandFixedString(i int) string

RandFixedString 根据[0-9]数字生成一位随机固定字符串[没有大小写oO]

func RandNum added in v0.13.1

func RandNum(length int) (str string)

RandNum 返回随机数字字符

func RandShortStringByDate added in v0.11.5

func RandShortStringByDate() (str string)

RandShortStringByDate 根据当前日期生成6位短字符串[以秒为单位不重复]

func RandString added in v0.0.7

func RandString() string

RandString 32位随机字符串 [不推荐使用]

func RandStringToOrderNoPrefix added in v1.2.5

func RandStringToOrderNoPrefix() string

func RemoveInvalid0 added in v0.2.9

func RemoveInvalid0(f float64) float64

RemoveInvalid0 去掉无效的0

func RemoveInvalid0ToString added in v0.2.9

func RemoveInvalid0ToString(f float64) string

RemoveInvalid0ToString 去掉无效的0并转为字符串格式

func Ripemd160 added in v0.2.8

func Ripemd160(str string) string

Ripemd160 RIPEMD-160加密[40位16进制数字]

func RoundFloat added in v0.2.2

func RoundFloat(f float64, n int) (res float64, err error)

RoundFloat 四舍五入 [n为保留的小数点位数] [优先使用]

func RoundToString added in v0.2.5

func RoundToString(f float64, n int) string

RoundToString 四舍五入后为字符串格式 [n为保留的小数点位数]

func RsaDecrypt added in v0.7.2

func RsaDecrypt(str, privateKey string) (string, error)

RsaDecrypt 使用私钥解密公钥加密的数据

func RsaDecryptByte added in v0.7.2

func RsaDecryptByte(cipherByte []byte, privateKey string) (decryptOAEP []byte, err error)

RsaDecryptByte 使用私钥解密公钥加密的数据

func RsaEncrypt added in v0.7.2

func RsaEncrypt(str, publicKey string) (string, error)

RsaEncrypt 使用公钥加密数据[只有私钥才能解开]

func RsaEncryptByte added in v0.7.2

func RsaEncryptByte(plain []byte, publicKey string) (cipherByte []byte, err error)

RsaEncryptByte 使用公钥加密数据[只有私钥才能解开]

func Sha1 added in v0.0.2

func Sha1(str string) string

Sha1 sha1加密

func Sha256 added in v0.2.8

func Sha256(str string) string

Sha256 sha256加密[64位16进制数字]

func Sha512 added in v0.2.8

func Sha512(str string) string

Sha512 sha512加密[128位16进制数字]

func SliceShuffle added in v0.12.2

func SliceShuffle(slice *[]string)

SliceShuffle 打乱切片

func SliceSort added in v1.2.2

func SliceSort(arr []int64) []int64

SliceSort 切片排序[倒序]

func SliceUnique added in v0.11.9

func SliceUnique(slice []string) []string

SliceUnique 切片去重

func SpellReadNum added in v0.0.18

func SpellReadNum(str string, formats ...SpellDigitalFormat) (slice []string, err error)

SpellReadNum 拼读数

func StringLength added in v0.11.6

func StringLength(str string) int

StringLength 获取字符串长度[包含中文字符串,一个中文字符串的长度为1]

func StringLengthCutAndSplitJoint added in v0.11.7

func StringLengthCutAndSplitJoint(str string, cutLength int, splitJointStr ...string) string

StringLengthCutAndSplitJoint 字符串长度截取并拼接处理

func StringLengthPadding added in v0.11.4

func StringLengthPadding(str string, length int) string

StringLengthPadding 字符串长度不够左侧填补0

func StringToFloat64 added in v0.2.7

func StringToFloat64(s string) (float64, error)

StringToFloat64 string转float64

func StringToInt64 added in v0.2.9

func StringToInt64(str string) (int64, error)

StringToInt64 string转int64

func StringToTime added in v0.7.0

func StringToTime(str string, layouts ...string) (time.Time, error)

StringToTime 将字符串转为时间[2021-08-08 08:08:08]

func StringYuanToInt64Fen added in v1.3.4

func StringYuanToInt64Fen(yuan string) (fen int64, err error)

StringYuanToInt64Fen 字符串元转int64分

func StructToMap added in v0.9.0

func StructToMap(s interface{}) (m map[string]string, err error)

StructToMap struct转map

func SubDays added in v0.3.0

func SubDays(t1, t2 time.Time) (day int)

SubDays 两个时间相隔多少天[t1减t2]

func SubMonths added in v0.3.0

func SubMonths(t1, t2 time.Time) (month int)

SubMonths 两个时间相隔多少个月[t1减t2][优先使用]

func TimeByDay added in v1.1.12

func TimeByDay(day int8, hour, minute, second int8) (t time.Time, err error)

TimeByDay 根据天数/号返回当前月的时间

func TimeNow added in v1.1.7

func TimeNow() time.Time

TimeNow 当前Time

func TimeNowUnix added in v1.1.7

func TimeNowUnix() int64

TimeNowUnix 当前时间戳

func TimestampToTime added in v0.0.4

func TimestampToTime(timestamp int64) time.Time

TimestampToTime 时间戳转时间

func ToBigCamelCase added in v0.2.4

func ToBigCamelCase(str string, signs ...string) (res string)

ToBigCamelCase 字符串转大驼峰格式

func ToSmallCamelCase added in v0.2.4

func ToSmallCamelCase(str string, signs ...string) (res string)

ToSmallCamelCase 字符串转小驼峰格式

func TodayStartAndEndTime added in v0.7.0

func TodayStartAndEndTime() (startTime, endTime time.Time)

TodayStartAndEndTime 今天00:00:00时间和今天23:59:59时间

func UcFirst added in v0.6.6

func UcFirst(str string) string

UcFirst 仅开头字母大写[将字符串中的第一个字母转换成大写]

func UcWords added in v0.6.6

func UcWords(str string) (res string)

UcWords 所有首字母大写[将字符串中每个单词的首字母转换成大写]

func UnicodeToChinese added in v0.12.5

func UnicodeToChinese(s string) (string, error)

UnicodeToChinese Unicode转中文

func UniqueId added in v0.3.6

func UniqueId(v ...interface{}) string

UniqueId 生成Guid字串

func UpInteger added in v0.4.2

func UpInteger(f float64) float64

UpInteger 向上取整

func UpIntegerToInt64 added in v0.4.4

func UpIntegerToInt64(f float64) int64

UpIntegerToInt64 向上取整返回int64

func UrlDecode added in v0.0.2

func UrlDecode(str string) string

UrlDecode url_decode

func UrlEncode added in v0.0.2

func UrlEncode(str string) string

UrlEncode url_encode

func VerifyECDSASign added in v0.7.2

func VerifyECDSASign(signData *ECDSASignData, publicKey *ecdsa.PublicKey) bool

VerifyECDSASign 校验数字签名

func WeekStartAndEndTime added in v0.7.3

func WeekStartAndEndTime(ts ...time.Time) (startTime, endTime time.Time)

WeekStartAndEndTime 该周一00:00:00时间和该周日23:59:59时间

func YearStartAndEndTime added in v0.7.3

func YearStartAndEndTime(ts ...time.Time) (startTime, endTime time.Time)

YearStartAndEndTime 该年1月1号00:00:00时间和该年12月31号23:59:59时间

func YuanToInt64Fen added in v1.3.4

func YuanToInt64Fen(yuan float64) (fen int64, err error)

YuanToInt64Fen 元转分

Types

type ECDSASignData added in v0.7.2

type ECDSASignData struct {
	// contains filtered or unexported fields
}

ECDSASignData 用于保存签名的数据

func ECDSASign added in v0.7.2

func ECDSASign(message string, privateKey *ecdsa.PrivateKey) (signData *ECDSASignData, err error)

ECDSASign 使用私钥签名一段数据

type SpellDigitalFormat added in v0.4.3

type SpellDigitalFormat map[string]string

SpellDigitalFormat 拼读格式

var RmbSpellDigitalFormat SpellDigitalFormat = map[string]string{
	"0": "零",
	"1": "壹",
	"2": "贰",
	"3": "叁",
	"4": "肆",
	"5": "伍",
	"6": "陆",
	"7": "柒",
	"8": "捌",
	"9": "玖",
	"s": "拾",
	"b": "佰",
	"q": "仟",
	"w": "万",
	"y": "亿",
	".": "点",
}

RmbSpellDigitalFormat 人民币大写拼读格式

Jump to

Keyboard shortcuts

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