Documentation
¶
Index ¶
- Constants
- type Birthday
- type Email
- func (e Email) Address() string
- func (e Email) DomainASCII() (string, error)
- func (e Email) Equal(o Email) bool
- func (e Email) IsEmpty() bool
- func (e Email) LocalPart() (string, error)
- func (e Email) MarshalJSON() ([]byte, error)
- func (e *Email) Scan(src any) error
- func (e Email) String() string
- func (e *Email) UnmarshalJSON(b []byte) error
- func (e Email) Value() (driver.Value, error)
- type Gender
- type Height
- type ID
- type IDCard
- type IDNumber
- func (id IDNumber) BirthDate() (time.Time, error)
- func (id IDNumber) Equal(o IDNumber) bool
- func (id IDNumber) IsEmpty() bool
- func (id IDNumber) IsMale() (bool, error)
- func (id IDNumber) MarshalJSON() ([]byte, error)
- func (id IDNumber) Number() string
- func (id IDNumber) ProvinceCode() string
- func (id *IDNumber) Scan(src any) error
- func (id IDNumber) String() string
- func (id *IDNumber) UnmarshalJSON(b []byte) error
- func (id IDNumber) Value() (driver.Value, error)
- type Phone
- func (p Phone) Equal(o Phone) bool
- func (p Phone) IsEmpty() bool
- func (p Phone) MarshalJSON() ([]byte, error)
- func (p Phone) Number() string
- func (p Phone) Region() (string, error)
- func (p *Phone) Scan(src any) error
- func (p Phone) String() string
- func (p *Phone) UnmarshalJSON(b []byte) error
- func (p Phone) Value() (driver.Value, error)
- type Weight
Constants ¶
const ZeroAsNull = true
0 是否当成 NULL 处理
const ZeroID = ID(0)
0 ID 常量
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Birthday ¶
type Birthday struct {
// contains filtered or unexported fields
}
type Email ¶
type Email struct {
// contains filtered or unexported fields
}
Email 邮箱值对象
func (Email) DomainASCII ¶
func (Email) MarshalJSON ¶
MarshalJSON 实现 json.Marshaler 接口,返回 JSON 编码值
func (*Email) UnmarshalJSON ¶
UnmarshalJSON 实现 json.Unmarshaler 接口,解析 JSON 编码值
type Height ¶
type Height struct {
// contains filtered or unexported fields
}
Height 表示以 0.1 单位存储的身高(单位:厘米,例如 170.5cm -> 1705)
func NewHeightFromFloat ¶
NewHeightFromFloat 创建一个新的 Height 实例,接受一个浮点数(单位:厘米)
func NewHeightFromTenths ¶
NewHeightFromTenths 从以 0.1 为单位的整数创建 Height 实例
func (Height) MarshalJSON ¶
JSON 序列化,输出 number(例如 170.5)
func (*Height) UnmarshalJSON ¶
JSON 反序列化,接受 number(例如 170.5)
type ID ¶
type ID int64
ID:用 int64 映射数据库 BIGINT,天然规避 > MaxInt64 的问题
func (*ID) UnmarshalJSON ¶
UnmarshalJSON 实现 json.Unmarshaler 接口
type IDNumber ¶
type IDNumber struct {
// contains filtered or unexported fields
}
func NewIDNumber ¶
NewIDNumber 解析/校验/归一化(支持 15 位旧号,自动转成 18 位)
func (IDNumber) MarshalJSON ¶
func (*IDNumber) UnmarshalJSON ¶
type Phone ¶
type Phone struct {
// contains filtered or unexported fields
}
Phone 电话号码值对象
func (Phone) MarshalJSON ¶
MarshalJSON 实现 json.Marshaler 接口,返回 JSON 编码值
func (*Phone) UnmarshalJSON ¶
UnmarshalJSON 实现 json.Unmarshaler 接口,解析 JSON 编码值
type Weight ¶
type Weight struct {
// contains filtered or unexported fields
}
Weight 表示以 0.1 单位存储的体重(单位:千克,例如 70.5kg -> 705)
func NewWeightFromFloat ¶
NewWeightFromFloat 创建一个新的 Weight 实例,接受一个浮点数(单位:千克)
func NewWeightFromTenths ¶
NewWeightFromTenths 从以 0.1 为单位的整数创建 Weight 实例
func (Weight) MarshalJSON ¶
JSON 序列化,输出 number(例如 170.5)
func (*Weight) UnmarshalJSON ¶
JSON 反序列化,接受 number(例如 170.5)