Skip to content

In-Memory database of provinces and cities in Iran

License

Notifications You must be signed in to change notification settings

mekramy/goircity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

goircity

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.

Installation

To install the package, run:

go get github.com/mekramy/goircity

Usage

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")
    }
}

API

Provinces() []IrProvince

Returns a list of all provinces.

FindProvince(code uint) *IrProvince

Finds and returns a province by its code. Returns nil if the province is not found.

Cities(province uint) []IrCity

Returns a list of cities in the specified province.

FindCity(code uint) *IrCity

Finds and returns a city by its code. Returns nil if the city is not found.

About

In-Memory database of provinces and cities in Iran

Topics

Resources

License

Stars

Watchers

Forks

Languages