countries
Countries - ISO 3166 (ISO3166-1, ISO3166, Digit, Alpha-2, Alpha-3) countries codes and names (on eng and rus), ISO 4217 currency designators, ITU-T E.164 IDD calling phone codes, countries capitals, UN M.49 regions codes, IANA ccTLD countries domains, IOC/NOC and FIFA codes, VERY FAST, NO maps[], NO slices[], NO init() funcs, NO external links/files/data, NO interface{}, NO specific dependencies, Databases/JSON/GOB/XML/CSV compatible, Emoji countries flags and currencies support, full support ISO-3166-1, ISO-4217, ITU-T E.164, Unicode CLDR and IANA ccTLD standarts.
Full support ISO-3166-1, ISO-4217, ITU-T E.164, Unicode CLDR and IANA ccTLD standarts.
installation
go get github.com/biter777/countries
usage
countryJapan := countries.Japan
fmt.Printf("Country name in english: %v\n", countryJapan)
fmt.Printf("Country name in russian: %v\n", countryJapan.StringRus())
fmt.Printf("Country ISO-3166 digit code: %d\n", countryJapan)
fmt.Printf("Country ISO-3166 Alpha-2 code: %v\n", countryJapan.Alpha2())
fmt.Printf("Country ISO-3166 Alpha-3 code: %v\n", countryJapan.Alpha3())
fmt.Printf("Country IOC/NOC code: %v\n", countryJapan.IOC())
fmt.Printf("Country FIFA code: %v\n", countryJapan.FIFA())
fmt.Printf("Country Capital: %v\n", countryJapan.Capital())
fmt.Printf("Country ITU-T E.164 call code: %v\n", countryJapan.CallCodes())
fmt.Printf("Country ccTLD domain: %v\n", countryJapan.Domain())
fmt.Printf("Country UN M.49 region name: %v\n", countryJapan.Region())
fmt.Printf("Country UN M.49 region code: %d\n", countryJapan.Region())
fmt.Printf("Country emoji/flag: %v\n\n", countryJapan.Emoji())
currencyJapan := countryJapan.Currency()
fmt.Printf("Country ISO-4217 Currency name in english: %v\n", currencyJapan)
fmt.Printf("Country ISO-4217 Currency digit code: %d\n", currencyJapan)
fmt.Printf("Country ISO-4217 Currency Alpha code: %v\n", currencyJapan.Alpha())
fmt.Printf("Country Currency emoji: %v\n", currencyJapan.Emoji())
fmt.Printf("Country of Currency %v: %v\n\n", currencyJapan, currencyJapan.Countries())
japanInfo := countries.Japan.Info()
fmt.Printf("Country name in english: %v\n", japanInfo.Name)
fmt.Printf("Country ISO-3166 digit code: %d\n", japanInfo.Code)
fmt.Printf("Country ISO-3166 Alpha-2 code: %v\n", japanInfo.Alpha2)
fmt.Printf("Country ISO-3166 Alpha-3 code: %v\n", japanInfo.Alpha3)
fmt.Printf("Country IOC/NOC code: %v\n", japanInfo.IOC)
fmt.Printf("Country FIFA code: %v\n", japanInfo.FIFA)
fmt.Printf("Country Capital: %v\n", japanInfo.Capital)
fmt.Printf("Country ITU-T E.164 call code: %v\n", japanInfo.CallCodes)
fmt.Printf("Country ccTLD domain: %v\n", japanInfo.Domain)
fmt.Printf("Country UN M.49 region name: %v\n", japanInfo.Region)
fmt.Printf("Country UN M.49 region code: %d\n", japanInfo.Region)
fmt.Printf("Country emoji/flag: %v\n", japanInfo.Emoji)
fmt.Printf("Country ISO-4217 Currency name in english: %v\n", japanInfo.Currency)
fmt.Printf("Country ISO-4217 Currency digit code: %d\n", japanInfo.Currency)
fmt.Printf("Country ISO-4217 Currency Alpha code: %v\n", japanInfo.Currency.Alpha())
country := countries.ByName("angola")
fmt.Printf("Country name in english: %v\n", country)
fmt.Printf("Country ISO-3166 digit code: %d\n", country)
fmt.Printf("Country ISO-3166 Alpha-2 code: %v\n", country.Alpha2())
fmt.Printf("Country ISO-3166 Alpha-3 code: %v\n", country.Alpha3())
country = countries.ByNumeric(24)
fmt.Printf("Country name in english: %v\n", country)
fmt.Printf("Country ISO-3166 digit code: %d\n", country)
fmt.Printf("Country ISO-3166 Alpha-2 code: %v\n", country.Alpha2())
fmt.Printf("Country ISO-3166 Alpha-3 code: %v\n", country.Alpha3())
if countries.ByName("angola") == countries.AGO {
fmt.Println("Yes! It's Angola!")
}
if strings.EqualFold("angola", countries.AGO.String()) {
fmt.Println("Yes! It's Angola!")
}
type User struct {
gorm.Model
Name string
Country countries.CountryCode
Currency 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")
if err != nil {
panic(err)
}
defer db.Close()
db.Create(user)
options
You can take a counties names in russian language, use StringRus(). For Emoji use Emoji(). Enjoy!
import "github.com/biter777/countries"
For more complex options, consult the documentation.
contributing
-
Welcome pull requests, bug fixes and issue reports.
Before proposing a change, please discuss it first by raising an issue.
Contributors list: @biter777, @gavincarr, @benja-M-1.
-
Donate. A donation isn't necessary, but it's welcome.
-
Star us. Give us a star, please, if it's not against your religion :)