Git Product home page Git Product logo

gountries's People

Contributors

bastengao avatar btburke avatar guillermo-menjivar avatar machadovilaca avatar melkstam avatar pariz avatar pbabbicola avatar perriea avatar pnfb avatar pyeremenko avatar rbuubr avatar rohithv-tw avatar tylerb avatar youhar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gountries's Issues

BQ & SH support

Carribean Netherlands (BQ) & Saint Helena (SH) country definitions are missing

FindCountryByName does not support official names

gountries.New().FindCountryByName("United States of America") 

does not return a country where this does

gountries.New().FindCountryByName("United States") 

"United States of America" should be valid based on

official: United States of America

name:
  common: United States
  official: United States of America

Please extend this method to include official and native text.

Thank you!

Few missing countries

Few missing countries:

  • Brunei Darussalam
  • Caribbean Netherlands
  • East Timor
  • Sao Tome and Principe
  • U.S. Virgin Islands

Embed data using go-bindata and use bi-directional map to speed up lookups

I'm planning on using your library as part of an API and I was going to make a few changes to get faster lookups and embed the data directly into the binary to make it easier to deploy. Interested in a pull request?

Planned features:

  1. Embed the country data from the YAML files using go-bindata so that the deployment remains a single binary without relying on an external data directory. This would be backwards compatible so that when you populateCountries or populateSubdivisions it checks the bindata first and then falls back to the data directory.
  2. Use a bidirectional tree map from the gods library so that lookups by either country name or alpha code are more efficient.
  3. Support returning either all of the data or a particular subset of countries as a struct that is easily marshaled to JSON. This is useful to populate a frontend web UI for entering billing/shipping addresses.

This could simplify some of the query functions by using the tree to do lookups, rather than looping through all of the available data.

I'm going to fork your library and work on this a little bit. Let me know if you have any other ideas.

Version Releases

Please add git releases to each build of this package, so that we can use them within our package management tool.

Issues with data directory

I faced with 2 issues

  • go get doesn't fetch content of data directory so it's empty after obtaining a project
  • example code fails with panic panic: Error loading Countries because it expects current directory of executable to contain data directory. But it's actually not there but inside github.com/pariz/gountries

Country methods re-parse the data every time they are used.

This makes the library pretty unsuitable for use in real-world applications. Currently, in order to get, e.g., a Country's list of Subdivisions, it creates a new Query every time you call it. This is horribly inefficient.

Probably the best way to solve this is make one Query and either make it a global variable that is initialized during package initialization, or allow it to be explicitly initialized if that isn't acceptable.

Error handling

Hello!

Would it be possible to either:

  • Remove the error formatting which introduces the gountries error part or
  • Make it customizable ?

Sometimes we want to return the error from gountries to expose what's wrong to the API user, but the gountries part can create confusion as to what's wrong.

Thanks!

Unicode symbols or \u codes?

Hello and thanks for sharing.

I noticed that your data contains unicode symbols in data/json/countries/ while \u<number> form is used in countries.json. Has it been done intentionally?

Is it possible to use plain unicode in countries.json too? I believe it's better for readability and grammar checking.

Country methods are inconsistent in receivers

The methods for countries sometimes take pointer receivers, and sometimes take struct receivers. They should be made consistent. My preference would be to use pointers everywhere in this library, because the data structures are frequently large and shouldn't be needlessly copied.

Source ?

Where does the source data (data directory) comes from?

Including translated names in NameToAlpha2

Would you be willing to accept a PR that adds translated country names to NameToAlpha2? I've run into several cases where lookups by name have failed but the spelling variant is among the translations.

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.