From 1a79c1e8f6584db0b378ce494bfac1a92d241b0b Mon Sep 17 00:00:00 2001 From: yaozm Date: Fri, 14 Jan 2022 16:26:14 +0800 Subject: [PATCH] Update annotation --- id_validator.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/id_validator.go b/id_validator.go index 712bb40..d3b1c76 100644 --- a/id_validator.go +++ b/id_validator.go @@ -12,7 +12,7 @@ import ( "github.com/guanguans/id-validator/data" ) -// 身份证信息 +// IdInfo 身份证信息 type IdInfo struct { AddressCode int Abandoned int @@ -26,7 +26,7 @@ type IdInfo struct { CheckBit string } -// 验证身份证号合法性 +// IsValid 验证身份证号合法性 func IsValid(id string, strict bool) bool { code, err := generateCode(id) if err != nil { @@ -47,11 +47,11 @@ func IsValid(id string, strict bool) bool { return code["checkBit"] == generatorCheckBit(code["body"]) } -// 获取身份证信息 +// GetInfo 获取身份证信息 func GetInfo(id string, strict bool) (IdInfo, error) { // 验证有效性 if !IsValid(id, strict) { - return IdInfo{}, errors.New("Not Valid ID card number.") + return IdInfo{}, errors.New("not Valid ID card number") } code, _ := generateCode(id) @@ -59,7 +59,7 @@ func GetInfo(id string, strict bool) (IdInfo, error) { // 地址信息 addressInfo := getAddressInfo(code["addressCode"], code["birthdayCode"], strict) - var addressTree []string + var addressTree []string //nolint:prealloc for _, val := range addressInfo { addressTree = append(addressTree, val) } @@ -98,12 +98,12 @@ func GetInfo(id string, strict bool) (IdInfo, error) { }, nil } -// 生成假身份证号码 +// FakeId 生成假身份证号码 func FakeId() string { return FakeRequireId(true, "", "", 0) } -// 按要求生成假身份证号码 +// FakeRequireId 按要求生成假身份证号码 // isEighteen 是否生成18位号码 // address 省市县三级地区官方全称:如`北京市`、`台湾省`、`香港特别行政区`、`深圳市`、`黄浦区` // birthday 出生日期:如 `2000`、`198801`、`19990101` @@ -137,10 +137,10 @@ func FakeRequireId(isEighteen bool, address string, birthday string, sex int) st return body + generatorCheckBit(body) } -// 15位升级18位号码 +// UpgradeId 15位升级18位号码 func UpgradeId(id string) (string, error) { if !IsValid(id, true) { - return "", errors.New("Not Valid ID card number.") + return "", errors.New("not Valid ID card number") } code, _ := generateShortCode(id)