chinaid

package module
v0.0.0-...-b6fbcf5 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2019 License: MIT Imports: 6 Imported by: 0

README

chinaid

Make or verify China ID

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidChinaID = errors.New("invalid China ID")

ErrInvalidChinaID error

Functions

func CheckCode

func CheckCode(idBody string) (string, bool)

CheckCode generates check code of chinese identity card number.

func Validate

func Validate(id string) bool

Validate judge whether chinese identity card number is valid.

Types

type ChinaID

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

ChinaID Chinese identity card number

func Make15

func Make15(addr [6]byte, birth [6]byte, seq [3]byte) (*ChinaID, bool)

Make15 generates an 15-character length number

func Make18

func Make18(addr [6]byte, birth [8]byte, seq [3]byte) (*ChinaID, bool)

Make18 generates an 18-character length number

func Parse

func Parse(id string) (*ChinaID, error)

Parse parse chinese identity card number to *ChinaID

func (*ChinaID) Addr

func (c *ChinaID) Addr() string

Addr returns address code

func (*ChinaID) Birth

func (c *ChinaID) Birth() string

Birth returns date of birth

func (*ChinaID) Body

func (c *ChinaID) Body() string

Body returns main part of chinese identity card number

func (*ChinaID) Check

func (c *ChinaID) Check() string

Check returns check code

func (*ChinaID) Format

func (c *ChinaID) Format(f fmt.State, r rune)

Format implements fmt.Formatter

func (*ChinaID) IsFemale

func (c *ChinaID) IsFemale() bool

IsMale judge whether is female or not

func (*ChinaID) IsMale

func (c *ChinaID) IsMale() bool

IsMale judge whether is male or not

func (*ChinaID) MarshalJSON

func (c *ChinaID) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler

func (*ChinaID) Seq

func (c *ChinaID) Seq() string

Seq returns sequence number in the persons whose date of birth are same

func (*ChinaID) Sex

func (c *ChinaID) Sex() int

Sex returns sex 1 male / 0 female

func (*ChinaID) SexText

func (c *ChinaID) SexText() string

SexText returns sex text, male or female

func (*ChinaID) String

func (c *ChinaID) String() string

String returns chinese identity card number

Jump to

Keyboard shortcuts

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