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.
This pull request packs the YAML data into bindata.go and relies on that first before falling back to the data directory. It also implements a couple of simple indexes to speed up the queries.
I only implemented two of the things I outlined in ref #5. go-bindata is used to pack the YAML files. This makes it so the library can be embedded in any binary without needing access to the data/ directory. I updated the readme with instructions for how to repack the data if there are changes to the YAML files.
The countries are now represented as a map[string]Country by Alpha2 key. Then a couple of simple indexes from common name -> alpha2 and alpha2 -> alpha3 are generated at the same time the query is initialized. This provides a pretty significant speed up:
All the tests pass. I added one simple query benchmark for looking up a country by name. I also added a sort to a couple of the tests to ensure that the test output comes out in a predictable order.
This pull request packs the YAML data into bindata.go and relies on that first before falling back to the data directory. It also implements a couple of simple indexes to speed up the queries.
I only implemented two of the things I outlined in ref #5. go-bindata is used to pack the YAML files. This makes it so the library can be embedded in any binary without needing access to the
data/
directory. I updated the readme with instructions for how to repack the data if there are changes to the YAML files.The countries are now represented as a
map[string]Country
by Alpha2 key. Then a couple of simple indexes from common name -> alpha2 and alpha2 -> alpha3 are generated at the same time the query is initialized. This provides a pretty significant speed up:All the tests pass. I added one simple query benchmark for looking up a country by name. I also added a sort to a couple of the tests to ensure that the test output comes out in a predictable order.