Description
Countries - ISO 3166 (ISO3166-1, ISO3166, Digit code, Alpha-2 and Alpha-3), ISO 4217 countries codes and names (on eng and rus), currency designators, calling phone codes (ITU-T E.164), countries capitals and regions (UN M.49 code), countries domains (IANA ccTLD), Very FAST, NO maps[], NO slices[], NO init() func, NO external files and data, NO interface{}, NO specific dependencies, Databases compatible, Emoji countries flags and currencies support, full support ISO-3166-1, ISO-4217, Unicode CLDR, IANA ccTLD, ITU-T E.164 and UN M.49 standarts.
Full support ISO-3166-1, ISO-4217, Unicode CLDR, IANA ccTLD, ITU-T E.164 and UN M.49 standarts.
countries alternatives and similar packages
Based on the "Miscellaneous" category.
Alternatively, view countries alternatives based on common mentions on social networks and blogs.
-
golang-standards/project-layout
Standard Go Project Layout -
go-formatter
A curated list of awesome Go frameworks, libraries and software -
archiver
Easily create & extract archives, and compress & decompress files of various formats -
ardanlabs/service
Starter code for writing web services in Go using Kubernetes. -
go-multierror
A Go (golang) package for representing a list of errors as a single error. -
go-restful-api
An idiomatic Go REST API starter kit (boilerplate) following the SOLID principles and Clean Architecture -
ghorg
Quickly clone an entire org/users repositories into one directory - Supports GitHub, GitLab, Bitbucket, and more 🥚 -
xstrings
Implements string functions widely used in other languages but absent in Go. -
go-shortid
Super short, fully unique, non-sequential and URL friendly Ids -
gountries
Gountries provides: Countries (ISO-3166-1), Country Subdivisions(ISO-3166-2), Currencies (ISO 4217), Geo Coordinates(ISO-6709) as well as translations, country borders and other stuff exposed as struct data. -
container
A lightweight yet powerful IoC dependency injection container for the Go programming language -
health
An easy to use, extensible health check library for Go applications. -
golang-templates/seed
Go application GitHub repository template. -
banner
An easy way to add useful startup banners into your Go applications -
go-starter
An opinionated production-ready SQL-/Swagger-first RESTful JSON API written in Go, highly integrated with VSCode DevContainers by allaboutapps. -
antch
Antch, a fast, powerful and extensible web crawling & scraping framework for Go
Static code analysis for 29 languages.
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of countries or a related project?
README
countries
Countries - 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, 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, Databases/JSON/GOB/XML/CSV compatible, Emoji countries flags and currencies support, full support ISO 3166-1,ISO 3166-2, ISO 4217, ITU-T E.164, Unicode CLDR and IANA ccTLD standarts.
Full support ISO 3166-1, ISO 3166-2, 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) // Japan
fmt.Printf("Country name in russian: %v\n", countryJapan.StringRus()) // Япония
fmt.Printf("Country ISO-3166 digit code: %d\n", countryJapan) // 392
fmt.Printf("Country ISO-3166 Alpha-2 code: %v\n", countryJapan.Alpha2()) // JP
fmt.Printf("Country ISO-3166 Alpha-3 code: %v\n", countryJapan.Alpha3()) // JPN
fmt.Printf("Country IOC/NOC code: %v\n", countryJapan.IOC()) // JPN
fmt.Printf("Country FIFA code: %v\n", countryJapan.FIFA()) // JPN
fmt.Printf("Country Capital: %v\n", countryJapan.Capital()) // Tokyo
fmt.Printf("Country ITU-T E.164 call code: %v\n", countryJapan.CallCodes()) // +81
fmt.Printf("Country ccTLD domain: %v\n", countryJapan.Domain()) // .jp
fmt.Printf("Country UN M.49 region name: %v\n", countryJapan.Region()) // Asia
fmt.Printf("Country UN M.49 region code: %d\n", countryJapan.Region()) // 142
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) // Yen
fmt.Printf("Country ISO-4217 Currency digit code: %d\n", currencyJapan) // 392
fmt.Printf("Country ISO-4217 Currency Alpha code: %v\n", currencyJapan.Alpha()) // JPY
fmt.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) // Japan
fmt.Printf("Country ISO-3166 digit code: %d\n", japanInfo.Code) // 392
fmt.Printf("Country ISO-3166 Alpha-2 code: %v\n", japanInfo.Alpha2) // JP
fmt.Printf("Country ISO-3166 Alpha-3 code: %v\n", japanInfo.Alpha3) // JPN
fmt.Printf("Country IOC/NOC code: %v\n", japanInfo.IOC) // JPN
fmt.Printf("Country FIFA code: %v\n", japanInfo.FIFA) // JPN
fmt.Printf("Country Capital: %v\n", japanInfo.Capital) // Tokyo
fmt.Printf("Country ITU-T E.164 call code: %v\n", japanInfo.CallCodes) // +81
fmt.Printf("Country ccTLD domain: %v\n", japanInfo.Domain) // .jp
fmt.Printf("Country UN M.49 region name: %v\n", japanInfo.Region) // Asia
fmt.Printf("Country UN M.49 region code: %d\n", japanInfo.Region) // 142
fmt.Printf("Country emoji/flag: %v\n", japanInfo.Emoji) // 🇯🇵
fmt.Printf("Country ISO-4217 Currency name in english: %v\n", japanInfo.Currency) // Yen
fmt.Printf("Country ISO-4217 Currency digit code: %d\n", japanInfo.Currency) // 392
fmt.Printf("Country ISO-4217 Currency Alpha code: %v\n", japanInfo.Currency.Alpha()) // JPY
// Detection usage
// Detect by name
country := countries.ByName("angola")
fmt.Printf("Country name in english: %v\n", country) // Angola
fmt.Printf("Country ISO-3166 digit code: %d\n", country) // 24
fmt.Printf("Country ISO-3166 Alpha-2 code: %v\n", country.Alpha2()) // AO
fmt.Printf("Country ISO-3166 Alpha-3 code: %v\n", country.Alpha3()) // AGO
// Detect by code/numeric
country = countries.ByNumeric(24)
fmt.Printf("Country name in english: %v\n", country) // Angola
fmt.Printf("Country ISO-3166 digit code: %d\n", country) // 24
fmt.Printf("Country ISO-3166 Alpha-2 code: %v\n", country.Alpha2()) // AO
fmt.Printf("Country ISO-3166 Alpha-3 code: %v\n", country.Alpha3()) // AGO
// Comparing usage
// Compare by code/numeric
if countries.ByName("angola") == countries.AGO {
fmt.Println("Yes! It's Angola!") // Yes! It's Angola!
}
// Compare by name
if strings.EqualFold("angola", countries.AGO.String()) {
fmt.Println("Yes! It's Angola!") // Yes! It's Angola!
}
// Database usage
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
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
Donate - a donation isn't necessary, but it's welcome.
Star us
Give us a star, please, if it's not against your religion :)
Updating ISO 3166
Making use of changes to the iso-codes project.
TODO create go generate capability to automatically generate from the json files in the data directory of the iso-codes project.
*Note that all licence references and agreements mentioned in the countries README section above
are relevant to that project's source code only.