Giter VIP home page Giter VIP logo

thibaultkpl / countries Goto Github PK

View Code? Open in Web Editor NEW

This project forked from biter777/countries

0.0 0.0 0.0 1.16 MB

Countries - ISO 3166 (ISO3166-1, ISO3166, Digit, Alpha-2 and 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, ccTLD countries domains, IOC/NOC and FIFA letters codes, VERY VERY FAST, NO maps[], NO slices[], NO init() funcs, NO external

Home Page: https://pkg.go.dev/github.com/biter777/countries?tab=doc

License: BSD 2-Clause "Simplified" License

Go 100.00%

countries's Introduction

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, compatible with Databases/JSON/BSON/GOB/XML/CSV, Emoji countries flags and currencies support, UN M.49, FIFA codes, full support ISO 3166-1, ISO 3166-2, ISO 4217, ITU-T E.164, Unicode CLDR and IANA ccTLD standarts.

Supported standarts:

  • ISO 3166-1
  • ISO 3166-2
  • ISO 4217
  • ITU-T E.164
  • IANA ccTLD
  • UN M.49
  • IOC
  • NOC
  • FIFA
  • Unicode CLDR
  • Unicode Emoticons Flags
  • Unicode Emoticons Currencies
  • UN World Countries Capitals

GoDev GoAwesome Coder Documentation Status DOI GolangCI codeclimate GolangCI GoReport Codiga Codacy Badge codecov Coverage Status Coverage ISO ITU IANA ICANN M49 CLDR License Build Status Build status Semaphore Status Build Status CLDR Codeship Status DMCA.com Protection Status Dependencies Free Gluten Free PRs Welcome DepShield Badge Stars

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", 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 Okinawa

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
fmt.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 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

  1. Welcome pull requests, bug fixes and issue reports

    Contributors list

  2. Donate - a donation isn't necessary, but it's welcome.

    Donate using Liberapay ko-fi

  3. Star us - give us a star, please, if it's not against your religion :)

    Stars

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.

countries's People

Contributors

biter777 avatar royshahaf-at-af avatar gavincarr avatar jufemaiz avatar royshahaf avatar andskur avatar benja-m-1 avatar darrahk avatar deepsourcebot avatar fcornelius avatar suquant avatar joshuabeny1999 avatar altynai avatar futuarmo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.