A go module providing a list of Algerian administrative areas with many useful APIs, based on dzcode-io/leblad
go get -u github.com/omdxp/leblad
package main
import (
"fmt"
"github.com/omdxp/leblad"
)
func main() {
l := leblad.New()
// Get all wilayas
wilayas, err := l.GetWilayaList()
if err != nil {
panic(err)
}
fmt.Println(wilayas)
// Get only wilayas names
wilayas, err = l.GetWilayaList("name")
if err != nil {
panic(err)
}
}
init a new leblad instance
l := leblad.New()
Get all wilayas
wilayas, err := l.GetWilayaList()
if err != nil {
panic(err)
}
Filter wilayas by a specific field
wilayas, err := l.GetWilayaList("name")
if err != nil {
panic(err)
}
it accept a variadic number of fields
wilayas, err := l.GetWilayaList("name", "dairats", "matricule")
if err != nil {
panic(err)
}
fields can be one of the following:
wilaya field | description |
---|---|
matricule | wilaya matricule |
name_ar | wilaya name in arabic |
name_ber | wilaya name in berber |
name_en | wilaya name in english |
name | wilaya name in french |
phoneCodes | wilaya phone codes |
postalCodes | wilaya postal codes |
dairats | wilaya dairats |
adjacentWilayas | wilaya adjacent wilayas |
Get wilaya by zip code
wilaya, err := l.GetWilayaByZipCode(1000)
if err != nil {
panic(err)
}
Filter wilaya by a specific field
wilaya, err := l.GetWilayaByZipCode(1000, "name")
if err != nil {
panic(err)
}
it accept a variadic number of fields
wilaya, err := l.GetWilayaByZipCode(1000, "name", "dairats", "matricule")
if err != nil {
panic(err)
}
Get wilaya by code
wilaya, err := l.GetWilayaByCode(1)
if err != nil {
panic(err)
}
Filter wilaya by a specific field
wilaya, err := l.GetWilayaByCode(1, "name")
if err != nil {
panic(err)
}
it accept a variadic number of fields
wilaya, err := l.GetWilayaByCode(1, "name", "dairats", "matricule")
if err != nil {
panic(err)
}
Get adjacent wilayas as a slice of wilaya codes
wilayas, err := l.GetAdjacentWilayas(1)
if err != nil {
panic(err)
}
Get zip codes for a wilaya
zipCodes, err := l.GetZipCodesForWilaya(1)
if err != nil {
panic(err)
}
Get dairats for a wilaya
dairats, err := l.GetDairatsForWilaya(1)
if err != nil {
panic(err)
}
Filter dairats by a specific field
dairats, err := l.GetDairatsForWilaya(1, "name")
if err != nil {
panic(err)
}
it accept a variadic number of fields
dairats, err := l.GetDairatsForWilaya(1, "name", "code", "baladyiats")
if err != nil {
panic(err)
}
fields can be one of the following:
daira field | description |
---|---|
code | daira code |
name | daira name |
name_ar | daira name in arabic |
name_en | daira name in english |
baladyiats | daira baladyiats |
Get wilaya by phone code
wilaya, err := l.GetWilayaByPhoneCode(49)
if err != nil {
panic(err)
}
Filter wilaya by a specific field
wilaya, err := l.GetWilayaByPhoneCode(49, "name")
if err != nil {
panic(err)
}
it accept a variadic number of fields
wilaya, err := l.GetWilayaByPhoneCode(49, "name", "dairats", "matricule")
if err != nil {
panic(err)
}
Get wilaya by daira name
wilaya, err := l.GetWilayaByDairaName("ADRAR")
if err != nil {
panic(err)
}
Filter wilaya by a specific field
wilaya, err := l.GetWilayaByDairaName("ADRAR", "name")
if err != nil {
panic(err)
}
it accept a variadic number of fields
wilaya, err := l.GetWilayaByDairaName("ADRAR", "name", "dairats", "matricule")
if err != nil {
panic(err)
}
Get baladyiats for a daira
baladyiats, err := l.GetBaladyiatsForDaira("ADRAR")
if err != nil {
panic(err)
}
Filter baladyiats by a specific field
baladyiats, err := l.GetBaladyiatsForDaira("ADRAR", "name")
if err != nil {
panic(err)
}
it accept a variadic number of fields
baladyiats, err := l.GetBaladyiatsForDaira("ADRAR", "name", "code")
if err != nil {
panic(err)
}
fields can be one of the following:
baladyia field | description |
---|---|
code | baladyia code |
name | baladyia name |
name_ar | baladyia name in arabic |
name_en | baladyia name in english |
Get baladyiats for a daira code
baladyiats, err := l.GetBaladyiatsForDairaCode(101)
if err != nil {
panic(err)
}
Filter baladyiats by a specific field
baladyiats, err := l.GetBaladyiatsForDairaCode(101, "name")
if err != nil {
panic(err)
}
it accept a variadic number of fields
baladyiats, err := l.GetBaladyiatsForDairaCode(101, "name", "code")
if err != nil {
panic(err)
}
Get phone codes for a wilaya
phoneCodes, err := l.GetPhoneCodesForWilaya("Adrar")
if err != nil {
panic(err)
}
Get first phone code for a wilaya
phoneCode, err := l.GetFirstPhoneCodeForWilaya("Adrar")
if err != nil {
panic(err)
}
Get baladyiats for a wilaya
baladyiats, err := l.GetBaladyiatsForWilaya("Adrar")
if err != nil {
panic(err)
}
Filter baladyiats by a specific field
baladyiats, err := l.GetBaladyiatsForWilaya("Adrar", "name")
if err != nil {
panic(err)
}
it accept a variadic number of fields
baladyiats, err := l.GetBaladyiatsForWilaya("Adrar", "name", "code")
if err != nil {
panic(err)
}
Get wilaya by baladyia name
wilaya, err := l.GetWilayaByBaladyiaName("ADRAR")
if err != nil {
panic(err)
}
Filter wilaya by a specific field
wilaya, err := l.GetWilayaByBaladyiaName("ADRAR", "name")
if err != nil {
panic(err)
}
it accept a variadic number of fields
wilaya, err := l.GetWilayaByBaladyiaName("ADRAR", "name", "dairats", "matricule")
if err != nil {
panic(err)
}
Get daira by baladyia name
daira, err := l.GetDairaByBaladyiaName("ADRAR")
if err != nil {
panic(err)
}
Filter daira by a specific field
daira, err := l.GetDairaByBaladyiaName("ADRAR", "name")
if err != nil {
panic(err)
}
it accept a variadic number of fields
daira, err := l.GetDairaByBaladyiaName("ADRAR", "name", "code")
if err != nil {
panic(err)
}
Contributions are welcome, please read the contributing guide for more information.