goircity
is a Go package that provides 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/mekramy/goircity
Here is an example of how to use the goircity
package:
package main
import (
"fmt"
"github.com/mekramy/goircity"
)
func main() {
// Get list of provinces
provinces := goircity.Provinces()
fmt.Println("Provinces:", provinces)
// Find a province by code
province := goircity.FindProvince(1)
if province != nil {
fmt.Println("Found Province:", *province)
} else {
fmt.Println("Province not found")
}
// Get list of cities in a province
cities := goircity.Cities(1)
fmt.Println("Cities in Province 1:", cities)
// Find a city by code
city := goircity.FindCity(101)
if city != nil {
fmt.Println("Found City:", *city)
} else {
fmt.Println("City not found")
}
}
Returns a list of all provinces.
Finds and returns a province by its code. Returns nil
if the province is not found.
Returns a list of cities in the specified province.
Finds and returns a city by its code. Returns nil
if the city is not found.