{"id":13413504,"url":"https://github.com/pariz/gountries","last_synced_at":"2026-01-16T17:27:49.250Z","repository":{"id":3455481,"uuid":"49559151","full_name":"pariz/gountries","owner":"pariz","description":"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.","archived":false,"fork":false,"pushed_at":"2024-06-04T07:45:23.000Z","size":2275,"stargazers_count":407,"open_issues_count":14,"forks_count":68,"subscribers_count":16,"default_branch":"master","last_synced_at":"2024-10-25T05:23:57.398Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pariz.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-01-13T08:04:18.000Z","updated_at":"2024-10-24T11:26:50.000Z","dependencies_parsed_at":"2024-06-04T08:53:31.049Z","dependency_job_id":"f46a3adb-fb6c-490d-ade1-38e0cf520829","html_url":"https://github.com/pariz/gountries","commit_stats":{"total_commits":69,"total_committers":16,"mean_commits":4.3125,"dds":0.5217391304347826,"last_synced_commit":"c2f72278d39811812e2d7fea1fc36322376b3ffa"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pariz%2Fgountries","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pariz%2Fgountries/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pariz%2Fgountries/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pariz%2Fgountries/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pariz","download_url":"https://codeload.github.com/pariz/gountries/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221498768,"owners_count":16833057,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T20:01:41.865Z","updated_at":"2024-10-26T05:31:03.746Z","avatar_url":"https://github.com/pariz.png","language":"Go","funding_links":[],"categories":["Microsoft Office","Miscellaneous","杂项","其他杂项","其他","\u003cspan id=\"其他-miscellaneous\"\u003e其他 Miscellaneous\u003c/span\u003e","Uncategorized"],"sub_categories":["Uncategorized","Advanced Console UIs","Strings","未分类的","暂未分类","交流","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e","暂未分类这些库被放在这里是因为其他类别似乎都不适合。"],"readme":"# gountries\n\n[![wercker status](https://app.wercker.com/status/909d6a059d7d0b49b74ec8b658f97df4/s/master \"wercker status\")](https://app.wercker.com/project/bykey/909d6a059d7d0b49b74ec8b658f97df4) [![codecov.io](https://codecov.io/github/pariz/gountries/coverage.svg?branch=master)](https://codecov.io/github/pariz/gountries?branch=master) [![Go Report Card](https://goreportcard.com/badge/pariz/gountries)](https://goreportcard.com/report/pariz/gountries)\n\nInspired by the [countries](https://github.com/hexorx/countries) gem for ruby.\n\nCountries (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.\n\nAll data is derived from the [pariz/countries](https://github.com/pariz/countries) repo.\n\n*This is currently a work in progress, so things may change. More stuff will be added*\n\n# Installation\n\n```\ngo get github.com/pariz/gountries\n```\n\n# Examples\n\n\n## Basic\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/pariz/gountries\"\n)\n\nfunc main() {\n\tquery := gountries.New()\n\n\t/////////////////\n\t// Find sweden //\n\t/////////////////\n\n\tsweden, _ := query.FindCountryByName(\"sweden\")\n\t// sweden, _ := query.FindCountryByAlpha(\"SE\")\n\t// sweden, _ := query.FindCountryByAlpha(\"SWE\")\n\n\tfmt.Println(sweden.Name.Common)   // Output: Sweden\n\tfmt.Println(sweden.Name.Official) // Output: Konungariket Sverige\n\n\tfmt.Println(sweden.Translations[\"DEU\"].Common)   // Output: Schweden\n\tfmt.Println(sweden.Translations[\"DEU\"].Official) // Output: Königreich Schweden\n}\n\n```\n## A bit more advanced\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/pariz/gountries\"\n)\n\nfunc main() {\n\n\tquery := gountries.New()\n\n\t////////////////////////////////////////////\n\t// Find the bordering countries of Sweden //\n\t////////////////////////////////////////////\n\n\tsweden, _ := query.FindCountryByAlpha(\"SWE\") // \"SE\" also works..\n\n\t// Get the bordering countries of sweden\n\tfor _, country := range sweden.BorderingCountries() {\n\t\tfmt.Println(country.Name.Common)\n\t}\n\n\t// Output:\n\t// Finland\n\t// Norway\n\n\t////////////////////////////////////\n\t// Find all subdivisons for Sweden //\n\t////////////////////////////////////\n\n\tsubdivisions := sweden.SubDivisions()\n\n\tfor _, subdivision := range subdivisions {\n\t\tfmt.Println(subdivision.Name)\n\t}\n\n\t// Output:\n\t// Västerbottens län\n\t// Uppsala län\n\t// Södermanlands län\n\t// Gotlands län\n\t// Dalarnas län\n\t// ...\n\n\t//////////////////////////////////////////////////////////\n\t// Find all countries bordering Germany and Switzerland //\n\t//////////////////////////////////////////////////////////\n\n\tcountryQuery := gountries.Country{\n\t\tBorders: []string{\n\t\t\t\"DEU\",\n\t\t\t\"CHE\",\n\t\t},\n\t}\n\n\tcountries := query.FindCountries(countryQuery)\n\n\tfor _, c := range countries {\n\t\tfmt.Println(c.Name.Common)\n\t}\n\n\t// Output:\n\t// Austria\n\t// France\n\n\t///////////////////////////////////////////////////////////////////\n\t// Calculate distance between Sweden and Germany (in Kilometers) //\n\t///////////////////////////////////////////////////////////////////\n\n\tse, _ := query.FindCountryByAlpha(\"SWE\")\n\tde, _ := query.FindCountryByAlpha(\"DEU\")\n\n\tdistance := gountries.MeasureDistanceHaversine(se, de)\n\t//distance := MeasureDistancePythagoras(se, de)\n\n\tfmt.Println(distance)\n\n\t// Output:\n\t// 1430.1937864547901\n\n\tdistance = gountries.CalculateHaversine(\n\t\tse.Coordinates.MaxLatitude, se.Coordinates.MaxLongitude,\n\t\tde.Coordinates.MinLatitude, de.Coordinates.MinLongitude)\n\n\tfmt.Println(distance)\n\n\t// Output:\n\t// 2641.26145088825\n}\n\n```\n\n# Using packed data\n\nThe data in the `data/yaml` subdirectory is embedded using go-bindata.  Once you include this library in your project, you won't need to access the data directory.  To add or update the data, make changes to the YAML files then run:\n\n```\ngo-bindata -pkg gountries data/yaml/*\n```\n\n# Testing\n\nHas a pretty solid test coverage but is constantly improving.\n\n# Todo\n- [ ] Province/County querying (partially complete)\n- [x] Measurement between coordinates\n- [ ] GeoJSON information\n- [ ] Suggestions?\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpariz%2Fgountries","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpariz%2Fgountries","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpariz%2Fgountries/lists"}