area

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2022 License: MIT Imports: 1 Imported by: 0

README

area

介绍

用于填写中国地区时的选择列表,包括省,市,区(县/镇)

安装教程

go get github.com/jageros/hawox

使用例子
package main

import (
	"fmt"
	"github.com/jageros/hawox/area"
)

func main() {
	ps := area.GetProvinces()
	fmt.Printf("省份列表:%v\n\n", ps.Strings())

	cs := area.GetCities("广东省")
	fmt.Printf("广东省城市列表:%v\n\n", cs.Strings())

	as := area.GetCounties("广东省", "广州市")
	fmt.Printf("广东省广州市区列表:%v\n\n", as.Strings())
}
使用说明
  1. GetProvinces() 获取省份列表
  2. GetCities(province string) []ICity / (p *Province) GetCities() []ICity 根据省份获取城市列表
  3. GetCounties(province, city string) / (c *City) GetCounties() []ICounty 根据省份和城市获取区(县,镇列表)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cities

type Cities []ICity

func GetCities

func GetCities(province string) Cities

func (Cities) Strings

func (cs Cities) Strings() []string

type City

type City struct {
	County
	Counties []*County `json:"children"`
	// contains filtered or unexported fields
}

func (*City) GetCounties

func (c *City) GetCounties() Counties

type Counties

type Counties []ICounty

func GetCounties

func GetCounties(province, city string) Counties

func (Counties) Strings

func (cs Counties) Strings() []string

type County

type County struct {
	Code string `json:"code"`
	Name string `json:"name"`
}

func (*County) GetCode

func (a *County) GetCode() string

func (*County) GetName

func (a *County) GetName() string

type ICity

type ICity interface {
	ICounty
	GetCounties() Counties
}

type ICounty

type ICounty interface {
	GetCode() string
	GetName() string
}

type IProvince

type IProvince interface {
	ICounty
	GetCities() Cities
}

type Province

type Province struct {
	County
	Cities []*City `json:"children"`
	// contains filtered or unexported fields
}

func (*Province) GetCities

func (p *Province) GetCities() Cities

type Provinces

type Provinces []IProvince

func GetProvinces

func GetProvinces() Provinces

func (Provinces) Strings

func (ps Provinces) Strings() []string

Jump to

Keyboard shortcuts

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