xutils

package
v0.0.0-...-325af03 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: Apache-2.0 Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ExcelTool excelTool
View Source
var PhoneRegExpMap = map[string]*PhoneRegExp{
	"CN": &PhoneRegExp{
		AreaNumber: "86",
		RegexpAll:  "^((00|\\+){0,1}86-){0,1}((13[0-9])|(14[579])|(15[0-9])|(16[567])|(18[0-9])|(17[0-8])|(19[13589]))\\d{8}$",
		Region:     "中国大陆",
		RegionCode: "CN",
	},
	"TEST": &PhoneRegExp{
		AreaNumber: "86",
		RegexpAll:  "^((00|\\+)?86-)?721\\d{8}$",
		Region:     "中国大陆",
		RegionCode: "CN",
	},
	"HK": &PhoneRegExp{
		AreaNumber: "852",
		RegexpAll:  "^((00|\\+){0,1}852-)(5|6|8|9)\\d{7}$",
		Region:     "中国香港",
		RegionCode: "HK",
	},
	"MO": &PhoneRegExp{
		AreaNumber: "853",
		RegexpAll:  "^((00|\\+){0,1}853-6)\\d{7}$",
		Region:     "中国澳门",
		RegionCode: "MO",
	},
	"TW": &PhoneRegExp{
		AreaNumber: "886",
		RegexpAll:  "^((00|\\+){0,1}886-09)\\d{8}$",
		Region:     "中国台湾",
		RegionCode: "TW",
	},
	"UAE": &PhoneRegExp{
		AreaNumber: "971",
		RegexpAll:  "^(00|\\+){0,1}971-0?5(0|2|5|6)\\d{7}$",
		Region:     "阿联酋",
		RegionCode: "UAE",
	},
	"AU": &PhoneRegExp{
		AreaNumber: "61",
		RegexpAll:  "^(00|\\+){0,1}61-0?[45]\\d{8}$",
		Region:     "澳大利亚",
		RegionCode: "AU",
	},
	"TL": &PhoneRegExp{
		AreaNumber: "670",
		RegexpAll:  "^(00|\\+){0,1}670-7\\d{7}$",
		Region:     "东帝汶",
		RegionCode: "TL",
	},
	"PH": &PhoneRegExp{
		AreaNumber: "63",
		RegexpAll:  "^(00|\\+){0,1}63-0?9\\d{9}$",
		Region:     "菲律宾",
		RegionCode: "PH",
	},
	"KR": &PhoneRegExp{
		AreaNumber: "82",
		RegexpAll:  "^(00|\\+){0,1}82-0?1\\d{9}$",
		Region:     "韩国",
		RegionCode: "KR",
	},
	"CA": &PhoneRegExp{
		AreaNumber: "1",
		RegexpAll:  "^(00|\\+){0,1}1-[1-9]\\d{9}$",
		Region:     "加拿大",
		RegionCode: "CA",
	},
	"KH": &PhoneRegExp{
		AreaNumber: "855",
		RegexpAll:  "^(00|\\+){0,1}855-0?85\\d{6}$",
		Region:     "柬埔寨",
		RegionCode: "KH",
	},
	"LA": &PhoneRegExp{
		AreaNumber: "856",
		RegexpAll:  "^(00|\\+){0,1}856-0?20\\d{7,8}$",
		Region:     "老挝",
		RegionCode: "LA",
	},
	"MY": &PhoneRegExp{
		AreaNumber: "60",
		RegexpAll:  "^(00|\\+){0,1}60-0?1(([02346789]\\d{7})|(1\\d{8}))$",
		Region:     "马来西亚",
		RegionCode: "MY",
	},
	"US": &PhoneRegExp{
		AreaNumber: "1",
		RegexpAll:  "^(00|\\+){0,1}1-[1-9]\\d{9}$",
		Region:     "美国",
		RegionCode: "US",
	},
	"MM": &PhoneRegExp{
		AreaNumber: "95",
		RegexpAll:  "^(00|\\+){0,1}95-0?[1-9]\\d{9}$",
		Region:     "缅甸",
		RegionCode: "MM",
	},
	"JP": &PhoneRegExp{
		AreaNumber: "81",
		RegexpAll:  "^(00|\\+){0,1}81-0?[1-9]\\d{9}$",
		Region:     "日本",
		RegionCode: "JP",
	},
	"TH": &PhoneRegExp{
		AreaNumber: "66",
		RegexpAll:  "^(00|\\+){0,1}66-0?[1-9]\\d{8}$",
		Region:     "泰国",
		RegionCode: "TH",
	},
	"BN": &PhoneRegExp{
		AreaNumber: "673",
		RegexpAll:  "^(00|\\+){0,1}673-((22[89])|(71\\d)|(72[0-3])|(8[1236789]\\d))\\d{4}$",
		Region:     "文莱",
		RegionCode: "BN",
	},
	"ES": &PhoneRegExp{
		AreaNumber: "34",
		RegexpAll:  "^(00|\\+){0,1}34-[6-7]\\d{8}$",
		Region:     "西班牙",
		RegionCode: "ES",
	},
	"SG": &PhoneRegExp{
		AreaNumber: "65",
		RegexpAll:  "^(00|\\+){0,1}65-[89]\\d{7}$",
		Region:     "新加坡",
		RegionCode: "SG",
	},
	"NZ": &PhoneRegExp{
		AreaNumber: "64",
		RegexpAll:  "^(00|\\+){0,1}64-0?2[012579]\\d{7,8}$",
		Region:     "新西兰",
		RegionCode: "NZ",
	},
	"ID": &PhoneRegExp{
		AreaNumber: "62",
		RegexpAll:  "^(00|\\+){0,1}62-0?8\\d{8,10}$",
		Region:     "印度尼西亚",
		RegionCode: "ID",
	},
	"UK": &PhoneRegExp{
		AreaNumber: "44",
		RegexpAll:  "^(00|\\+){0,1}44-0?7\\d{9}$",
		Region:     "英国",
		RegionCode: "UK",
	},
	"VN": &PhoneRegExp{
		AreaNumber: "84",
		RegexpAll:  "^(00|\\+){0,1}84-0?[1-9]\\d{9}$",
		Region:     "越南",
		RegionCode: "VN",
	},
}

Functions

func Any2String

func Any2String(v any) (str string)

func Bytes2Str

func Bytes2Str(b []byte) string

func Concat

func Concat(strings ...string) string

func FilterEmoji

func FilterEmoji(s string) string

func GetStandardPhone

func GetStandardPhone(phone string, star bool) string

GetStandardPhone 返回标准手机号,支持加密

func ParsePhone

func ParsePhone(phone string) (area string, number string)

ParsePhone 通用的手机号解析,以及检查 手机号格式为:国家区号-手机号 国家区号和手机号使用"-"进行分割 例如: 86-15000000000 没有-号的,按照86进行处理

func RegularPhone

func RegularPhone(phone string) string

RegularPhone *

  • @Description: 规则化手机号
  • @param phone 必须是已通过正则校验的手机号,如+86-18812341919,0086-18812341919,86-18812341919,18812341919(仅限中国大陆可不带区号)
  • @return string 返回规则化的手机号,如86-18812341919,852-18812341919

func SBC2DBC

func SBC2DBC(str string) string

func Str2Bytes

func Str2Bytes(s string) []byte

func StrLen

func StrLen(str string) int

func UCFirst

func UCFirst(str string) string

UCFirst 首写字母大写

func WaitAllFutures

func WaitAllFutures(ctx context.Context, futures ...*Future)

WaitAllFutures wait all futures done

func WorldPhone

func WorldPhone(area, number string) string

WorldPhone 获取带区号的手机号

func WorldPhoneFmt

func WorldPhoneFmt(phone string) string

WorldPhoneFmt 输入的是一个可能不带区号,也可能带的号 返回一个规范的,肯定带着区号的表示

Types

type Func

type Func func() error

Func function of future

type Future

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

Future safe goroutine

func NewFuture

func NewFuture(fn Func) *Future

NewFuture create a future

func (*Future) Done

func (f *Future) Done() bool

Done check if future done

func (*Future) Get

func (f *Future) Get(ctx context.Context) error

Get return result of future

type PhoneRegExp

type PhoneRegExp struct {
	AreaNumber string `json:"AreaNumber"`
	RegexpAll  string `json:"regexp_all"`
	Region     string `json:"region"`
	RegionCode string `json:"region_code"`
}

type PhoneVerifyReq

type PhoneVerifyReq struct {
	Phone      string `json:"phone"`       // 手机号
	RegionCode string `json:"region_code"` // 国家或地区缩写
}

PhoneVerifyReq 手机号验证请求

type PhoneVerifyRes

type PhoneVerifyRes struct {
	Ok           bool   `json:"ok"`
	RegularPhone string `json:"regular_phone"` // 规则化的手机号,如 86-18812341919,852-18812341919
	AreaNumber   string `json:"area_number"`   // 区号
	Region       string `json:"region"`        // 国家或地区
	RegionCode   string `json:"region_code"`   // 国家或地区缩写
}

PhoneVerifyRes 手机号验证结果

func RegexpPhoneVerify

func RegexpPhoneVerify(req PhoneVerifyReq) PhoneVerifyRes

RegexpPhoneVerify *

  • @Description:手机号正则验证
  • 支持验证的国家和地区有:{中国大陆-CN,中国香港-HK,中国澳门-MO,中国台湾-TW,阿联酋-UAE,澳大利亚-AU,东帝汶-TL,菲律宾-PH,韩国-KR
  • 加拿大-CA,柬埔寨-KH,老挝-LA,马来西亚-MY,美国-US,缅甸-MM,日本-JP,泰国-TH,文莱-BN,西班牙-ES,新加坡-SG,新西兰-NZ,印度尼西亚-ID
  • 英国-UK,越南-VN},不支持的一律返回false。
  • 仅中国大陆手机号可不带区号。其余必须为+86-phone,0086-phone,86-phone这样的
  • @param req{Phone:手机号,RegionCode:国家或地区缩写,如"CN","HK"} 注:RegionCode为空则遍历所有Region匹配校验
  • @return PhoneVerifyRes{Ok:正确/错误,RegularPhone:规则化的手机号,AreaNumber:区号,Region:手机号所属国家或地区,RegionCode:国家或地区缩写}

type VersionCmp

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

func NewVersionCmp

func NewVersionCmp(ver string) *VersionCmp

func (*VersionCmp) Eq

func (m *VersionCmp) Eq(ver string) bool

func (*VersionCmp) GetFormatVersion

func (m *VersionCmp) GetFormatVersion() string

func (*VersionCmp) Gt

func (m *VersionCmp) Gt(ver string) bool

func (*VersionCmp) Gte

func (m *VersionCmp) Gte(ver string) bool

func (*VersionCmp) Lt

func (m *VersionCmp) Lt(ver string) bool

func (*VersionCmp) Lte

func (m *VersionCmp) Lte(ver string) bool

func (*VersionCmp) Max

func (m *VersionCmp) Max() string

func (*VersionCmp) Min

func (m *VersionCmp) Min() string

func (*VersionCmp) Ne

func (m *VersionCmp) Ne(ver string) bool

Directories

Path Synopsis
Package sync2 provides extra functionality along the same lines as sync.
Package sync2 provides extra functionality along the same lines as sync.

Jump to

Keyboard shortcuts

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