- Notifications
You must be signed in to change notification settings - Fork77
Countries - ISO-639, ISO-3166 countries codes with subdivisions and names, ISO-4217 currency designators, ITU-T E.164 IDD phone codes, countries capitals, UN M.49 codes, IANA ccTLD countries domains, FIPS, IOC/NOC and FIFA codes, VERY VERY FAST, compatible with Databases/JSON/BSON/GOB/XML/CSV, Emoji countries flags and currencies, Unicode CLDR.
License
biter777/countries
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Countries - ISO 639, ISO 3166 (ISO3166-1, ISO3166, Digit, Alpha-2, Alpha-3) countries codes with subdivisions and names (on eng and rus), ISO4217 currency designators, ITU-T E.164 IDD calling phone codes, countries capitals, UN M.49 regions codes, IANA ccTLD countries domains, FIPS, IOC/NOC and FIFA codes,VERY VERY FAST, NO maps[], NO slices[], NO init() funcs, NO external links/files/data, NO interface{}, NO specific dependencies, compatible with Databases/JSON/BSON/GOB/XML/CSV, Emoji countries flags and currencies support, UN M.49, FIFA codes, full support ISO 639-1, ISO 3166-1, ISO 3166-2, ISO 4217, ITU-T E.164, Unicode CLDR and IANA ccTLD standarts.
Supported standarts:
- ISO 639-1
- ISO 3166-1
- ISO 3166-2
- ISO 4217
- ICANN
- IANA ccTLD
- ITU-T E.164
- IOC
- NOC
- FIFA
- FIPS
- UN M.49
- Unicode CLDR
- Unicode Emoticons Flags
- Unicode Emoticons Currencies
- UN World Countries Capitals
go get github.com/biter777/countries
countryJapan:=countries.Japanfmt.Printf("Country name in english: %v\n",countryJapan)// Japanfmt.Printf("Country name in russian: %v\n",countryJapan.StringRus())// Японияfmt.Printf("Country ISO-3166 digit code: %d\n",countryJapan)// 392fmt.Printf("Country ISO-3166 Alpha-2 code: %v\n",countryJapan.Alpha2())// JPfmt.Printf("Country ISO-3166 Alpha-3 code: %v\n",countryJapan.Alpha3())// JPNfmt.Printf("Country IOC/NOC code: %v\n",countryJapan.IOC())// JPNfmt.Printf("Country FIFA code: %v\n",countryJapan.FIFA())// JPNfmt.Printf("Country FIPS code: %v\n",countryJapan.FIPS())// JAfmt.Printf("Country Capital: %v\n",countryJapan.Capital())// Tokyofmt.Printf("Country ITU-T E.164 call code: %v\n",countryJapan.CallCodes())// +81fmt.Printf("Country ccTLD domain: %v\n",countryJapan.Domain())// .jpfmt.Printf("Country UN M.49 region name: %v\n",countryJapan.Region())// Asiafmt.Printf("Country UN M.49 region code: %d\n",countryJapan.Region())// 142fmt.Printf("Country emoji/flag: %v\n",countryJapan.Emoji())// 🇯🇵fmt.Printf("Country Subdivisions: %v\n",countryJapan.Subdivisions())// Hokkaido Aomori Iwate Miyagi Akita Yamagata Fukushima Ibaraki Tochigi Gunma Saitama Chiba Tokyo Kanagawa Niigata Toyama Ishikawa Fukui Yamanashi Nagano Gifu Shizuoka Aichi Mie Shiga Kyoto Osaka Hyogo Nara Wakayama Tottori Shimane Okayama Hiroshima Yamaguchi Tokushima Kagawa Ehime Kochi Fukuoka Saga Nagasaki Kumamoto Oita Miyazaki Kagoshima OkinawacurrencyJapan:=countryJapan.Currency()fmt.Printf("Country ISO-4217 Currency name in english: %v\n",currencyJapan)// Yenfmt.Printf("Country ISO-4217 Currency digit code: %d\n",currencyJapan)// 392fmt.Printf("Country ISO-4217 Currency Alpha code: %v\n",currencyJapan.Alpha())// JPYfmt.Printf("Country Currency emoji: %v\n",currencyJapan.Emoji())// 💴fmt.Printf("Country of Currency %v: %v\n\n",currencyJapan,currencyJapan.Countries())// Japan// OR you can alternative use:japanInfo:=countries.Japan.Info()fmt.Printf("Country name in english: %v\n",japanInfo.Name)// Japanfmt.Printf("Country ISO-3166 digit code: %d\n",japanInfo.Code)// 392fmt.Printf("Country ISO-3166 Alpha-2 code: %v\n",japanInfo.Alpha2)// JPfmt.Printf("Country ISO-3166 Alpha-3 code: %v\n",japanInfo.Alpha3)// JPNfmt.Printf("Country IOC/NOC code: %v\n",japanInfo.IOC)// JPNfmt.Printf("Country FIFA code: %v\n",japanInfo.FIFA)// JPNfmt.Printf("Country FIPS code: %v\n",japanInfo.FIPS)// JAfmt.Printf("Country Capital: %v\n",japanInfo.Capital)// Tokyofmt.Printf("Country ITU-T E.164 call code: %v\n",japanInfo.CallCodes)// +81fmt.Printf("Country ccTLD domain: %v\n",japanInfo.Domain)// .jpfmt.Printf("Country UN M.49 region name: %v\n",japanInfo.Region)// Asiafmt.Printf("Country UN M.49 region code: %d\n",japanInfo.Region)// 142fmt.Printf("Country emoji/flag: %v\n",japanInfo.Emoji)// 🇯🇵fmt.Printf("Country ISO-4217 Currency name in english: %v\n",japanInfo.Currency)// Yenfmt.Printf("Country ISO-4217 Currency digit code: %d\n",japanInfo.Currency)// 392fmt.Printf("Country ISO-4217 Currency Alpha code: %v\n",japanInfo.Currency.Alpha())// JPYfmt.Printf("Country Subdivisions: %v\n",japanInfo.Subdivisions)// Hokkaido Aomori Iwate Miyagi Akita Yamagata Fukushima Ibaraki Tochigi Gunma Saitama Chiba Tokyo Kanagawa Niigata Toyama Ishikawa Fukui Yamanashi Nagano Gifu Shizuoka Aichi Mie Shiga Kyoto Osaka Hyogo Nara Wakayama Tottori Shimane Okayama Hiroshima Yamaguchi Tokushima Kagawa Ehime Kochi Fukuoka Saga Nagasaki Kumamoto Oita Miyazaki Kagoshima Okinawa// Detection/Lookup usage// Detect/Lookup by country namecountry:=countries.ByName("angola")fmt.Printf("Country name in english: %v\n",country)// Angolafmt.Printf("Country ISO-3166 digit code: %d\n",country)// 24fmt.Printf("Country ISO-3166 Alpha-2 code: %v\n",country.Alpha2())// AOfmt.Printf("Country ISO-3166 Alpha-3 code: %v\n",country.Alpha3())// AGO// Detect/Lookup by country codecountry=countries.ByName("AO")fmt.Printf("Country name in english: %v\n",country.String())// Angolafmt.Printf("Country ISO-3166 digit code: %d\n",country)// 24fmt.Printf("Country ISO-3166 Alpha-2 code: %v\n",country.Alpha2())// AOfmt.Printf("Country ISO-3166 Alpha-3 code: %v\n",country.Alpha3())// AGO// Detect/Lookup by code/numericcountry=countries.ByNumeric(24)fmt.Printf("Country name in english: %v\n",country)// Angolafmt.Printf("Country ISO-3166 digit code: %d\n",country)// 24fmt.Printf("Country ISO-3166 Alpha-2 code: %v\n",country.Alpha2())// AOfmt.Printf("Country ISO-3166 Alpha-3 code: %v\n",country.Alpha3())// AGO// Comparing usage// Compare by code/numericifcountries.ByName("angola")==countries.AGO {fmt.Println("Yes! It's Angola!")// Yes! It's Angola!}// Compare by nameifstrings.EqualFold("angola",countries.AGO.String()) {fmt.Println("Yes! It's Angola!")// Yes! It's Angola!}// Database usagetypeUserstruct {gorm.ModelNamestringCountry countries.CountryCodeCurrency countries.CurrencyCode}user:=&User{Name:"Helen",Country:countries.Slovenia,Currency:countries.CurrencyEUR}db,err:=gorm.Open("postgres",500,"host=127.0.0.2 port=5432 user=usr password=1234567 dbname=db")iferr!=nil {panic(err)}deferdb.Close()db.Create(user)
For Emoji use Emoji(). Enjoy!
import"github.com/biter777/countries"
For more complex options, consult thedocumentation.
Welcome pull requests, bug fixes and issue reports
Donate - a donation isn't necessary, but it's welcome.
Star us - give us a star, please, if it's not against your religion :)
Making use of changes to theiso-codes project.
TODO create go generate capability to automatically generate from the json filesin thedatadirectory of the iso-codes project.
About
Countries - ISO-639, ISO-3166 countries codes with subdivisions and names, ISO-4217 currency designators, ITU-T E.164 IDD phone codes, countries capitals, UN M.49 codes, IANA ccTLD countries domains, FIPS, IOC/NOC and FIFA codes, VERY VERY FAST, compatible with Databases/JSON/BSON/GOB/XML/CSV, Emoji countries flags and currencies, Unicode CLDR.