Documentation ¶
Overview ¶
addresscn can parse address string to standardize China address. 初始化阶段如果出错 会直接 panic
Index ¶
- Variables
- type Address
- type AddressUpdate
- type Area
- type City
- type Client
- func (c *Client) AreaName(code string) (string, error)
- func (c *Client) CityName(code string) (string, error)
- func (c *Client) GetPCA() (io.ReadCloser, error)
- func (c *Client) LoadArea(r io.Reader)
- func (c *Client) LoadCity(r io.Reader)
- func (c *Client) LoadProvince(r io.Reader)
- func (c *Client) MustParseAddress(src string) (Address, error)
- func (c *Client) ParseAddress(src string) (Address, error)
- func (c *Client) ParseCity(name string) (City, error)
- func (c *Client) ParseProvince(name string) (string, error)
- func (c *Client) ProvinceName(code string) (string, error)
- type Province
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ProviderGithub = "github" ProviderCOS = "cos" )
View Source
var (
ErrorNotFound = errors.New("address code not found")
)
Functions ¶
This section is empty.
Types ¶
type Address ¶
type Address struct { ProvinceCode string `json:"province_code" gorm:"type:varchar(2)"` // 省 必填 CityCode string `json:"city_code" gorm:"type:varchar(4)"` // 市 必填 AreaCode string `json:"area_code" gorm:"type:varchar(6)"` // 区 必填 Detail string `json:"detail" gorm:"type:varchar(255)"` // 街道一下具体地址 必填 ZipCode string `json:"zip_code" gorm:"type:varchar(6)"` // 邮编 非必填 }
Address 通信地址
type AddressUpdate ¶
type AddressUpdate struct { ProvinceCode *string `json:"province_code" gorm:"type:varchar(2)"` // 省 必填 CityCode *string `json:"city_code" gorm:"type:varchar(4)"` // 市 必填 AreaCode *string `json:"area_code" gorm:"type:varchar(6)"` // 区 必填 Detail *string `json:"detail" gorm:"type:varchar(255)"` // 街道一下具体地址 必填 ZipCode *string `json:"zip_code" gorm:"type:varchar(6)"` // 邮编 非必填 }
AddressUpdate 通信地址修改,供 RESTFUL 请求绑定使用
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client 地址解析客户端 请调用方保证初始化完成后再使用 这些数据在初始化阶段完成写入,提供服务后不再写入,所以只有并行读取,是线程安全的。
func NewFromGithub ¶
func NewFromGithub() *Client
NewFromGithub 从 modood/Administrative-divisions-of-China 库初始化
func (*Client) GetPCA ¶
func (c *Client) GetPCA() (io.ReadCloser, error)
GetPCA load the province city area stream from cos.
func (*Client) LoadProvince ¶
LoadProvince load the province data from a io reader.
func (*Client) MustParseAddress ¶
MustParseAddress 解析地址 报告任何错误
func (*Client) ParseAddress ¶
ParseAddress 解析地址 省市解析成功就算成功 忽略区解析失败的错误
func (*Client) ParseProvince ¶
ParseProvince 从名字解析省份代码
Click to show internal directories.
Click to hide internal directories.