ircity
is a Go package that provides an in-memory database of provinces and cities in Iran. It allows you to retrieve lists of provinces and cities, as well as find specific provinces or cities by their codes.
To install the package, run:
go get github.com/go-universal/ircity
Here is an example of how to use the ircity
package:
package main
import (
"fmt"
"github.com/go-universal/ircity"
)
func main() {
// Get list of provinces
provinces := ircity.Provinces()
fmt.Println("Provinces:", provinces)
// Find a province by code
province := ircity.FindProvince(1)
if province != nil {
fmt.Println("Found Province:", *province)
} else {
fmt.Println("Province not found")
}
// Get list of cities in a province
cities := ircity.Cities(1)
fmt.Println("Cities in Province 1:", cities)
// Find a city by code
city := ircity.FindCity(101)
if city != nil {
fmt.Println("Found City:", *city)
} else {
fmt.Println("City not found")
}
}
Returns a list of all provinces.
provinces := ircity.Provinces()
fmt.Println(provinces)
Finds and returns a province by its code. Returns nil
if the province is not found.
code
(uint): The code of the province to find.
province := ircity.FindProvince(1)
if province != nil {
fmt.Println("Found Province:", *province)
} else {
fmt.Println("Province not found")
}
Returns a list of cities in the specified province.
province
(uint): The code of the province whose cities you want to retrieve.
cities := ircity.Cities(1)
fmt.Println("Cities in Province 1:", cities)
Finds and returns a city by its code. Returns nil
if the city is not found.
code
(uint): The code of the city to find.
city := ircity.FindCity(101)
if city != nil {
fmt.Println("Found City:", *city)
} else {
fmt.Println("City not found")
}
Represents a province in Iran.
Code
(uint): The unique code of the province.Name
(string): The name of the province.
Represents a city in Iran.
Code
(uint): The unique code of the city.Name
(string): The name of the city.ProvinceCode
(uint): The code of the province to which the city belongs.Province
(*Province): The province to which the city belongs.
This project is licensed under the ISC License. See the LICENSE file for details.