biter777 / countries

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.
https://pkg.go.dev/github.com/biter777/countries?tab=doc
BSD 2-Clause "Simplified" License
412 stars 76 forks source link

Incorrect handling of GB alpha2 codes for main countries #73

Open joh-ku opened 6 months ago

joh-ku commented 6 months ago

When searching for countries.ByName("scotland") the return value is GB.

For Scotland the correct ISO-3166-2 code should be GB-SCT instead. Same applies for all other main countries in UK, which don't have a parent subdivision.

Those are:

  1. England -> GB-ENG
  2. Northern Ireland -> GB-NIR
  3. Scotland -> GB-SCT
  4. Wales -> GB-WLS

See https://www.iso.org/obp/ui/#iso:code:3166:GB.

I'm happy to provide a PR, if the change is accepted.

biter777 commented 5 months ago

Ok Do a pr pls, if u can

ccoVeille commented 5 months ago

My main concern is the fact the lib may return an ISO code with more than 2 characters. Some database or code may react badly, because value will exceed field capacity

So, what about a new method ? that will provide such an extended code that will return the existing 2 letter code except for these variants.

So keep returning iso code to GB for existing method. Scotland is part of GB after all.

If someone asks the country code of Scotland they would expect getting GB I think.

I'm a bit afraid of breaking change