finds.dev← search

// the find

biter777/countries

★ 518 · Go · BSD-2-Clause · updated May 2024

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.

A Go library that encodes country, currency, language, and phone code data entirely as typed constants — no maps, no init(), no runtime lookups. Every country is a typed integer constant (CountryCode), so the compiler catches typos and comparisons are O(1). Aimed at Go developers who need to store or compare country/currency codes without pulling in a database or a JSON file at startup.

All data is compile-time constants, so there's zero initialization cost and no heap allocations for basic lookups. The typed integer approach means invalid country codes are a compile error, not a runtime panic. It covers an unusually wide spread of standards in one package — ISO 3166-1/2, ISO 4217, ITU-T E.164, IANA ccTLD, FIFA, FIPS, UN M.49 — without any external dependencies. Database integration is straightforward since CountryCode and CurrencyCode implement the standard sql.Scanner/driver.Valuer interfaces.

Only English and Russian names are included — if your app needs country names in any other language, you're on your own. Updates to ISO standards require manual code changes; the README itself acknowledges the `go generate` pipeline is a TODO, so keeping pace with real-world country changes (South Sudan, Kosovo, etc.) is a manual process and the last commit was May 2024. Subdivision data is present but thin — you get a flat list of names, not a structured hierarchy with ISO 3166-2 codes you can actually use for validation. The 'VERY VERY FAST' claim in the README is technically true but somewhat meaningless — you're comparing integer constants, of course it's fast.

View on GitHub → Homepage ↗

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →