{"id":13414116,"url":"https://github.com/pioz/countries","last_synced_at":"2025-10-08T21:38:07.315Z","repository":{"id":59046208,"uuid":"532221916","full_name":"pioz/countries","owner":"pioz","description":"All you need when you are working with countries in Go.","archived":false,"fork":false,"pushed_at":"2023-10-06T10:33:38.000Z","size":11793,"stargazers_count":92,"open_issues_count":1,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-08T21:38:02.830Z","etag":null,"topics":["countries","go","golang"],"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/pioz.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":"2022-09-03T10:05:46.000Z","updated_at":"2025-07-18T16:23:40.000Z","dependencies_parsed_at":"2024-06-20T17:34:04.566Z","dependency_job_id":"875f4828-e66e-4348-8826-eea9c90c58fe","html_url":"https://github.com/pioz/countries","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/pioz/countries","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pioz%2Fcountries","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pioz%2Fcountries/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pioz%2Fcountries/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pioz%2Fcountries/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pioz","download_url":"https://codeload.github.com/pioz/countries/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pioz%2Fcountries/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000708,"owners_count":26082837,"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","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["countries","go","golang"],"created_at":"2024-07-30T20:01:58.130Z","updated_at":"2025-10-08T21:38:07.295Z","avatar_url":"https://github.com/pioz.png","language":"Go","funding_links":[],"categories":["Utilities","公用事业公司"],"sub_categories":["Utility/Miscellaneous","实用程序/Miscellaneous"],"readme":"# Countries\n\n![Go](https://github.com/pioz/countries/workflows/Go/badge.svg)\n[![Go Report Card](https://goreportcard.com/badge/github.com/pioz/countries)](https://goreportcard.com/report/github.com/pioz/countries)\n[![codecov](https://codecov.io/gh/pioz/countries/branch/master/graph/badge.svg)](https://codecov.io/gh/pioz/countries)\n[![awesome-go](https://camo.githubusercontent.com/13c4e50d88df7178ae1882a203ed57b641674f94/68747470733a2f2f63646e2e7261776769742e636f6d2f73696e647265736f726875732f617765736f6d652f643733303566333864323966656437386661383536353265336136336531353464643865383832392f6d656469612f62616467652e737667)](https://github.com/avelino/awesome-go)\n[![GoReference](https://pkg.go.dev/badge/mod/github.com/pioz/countries)](https://pkg.go.dev/github.com/pioz/countries)\n\nCountries is a port of [Ruby Countries](https://github.com/countries/countries) for Go.\n\n- Standard ISO3166-1 (countries)\n- Standard ISO3166-2 (states/subdivisions)\n- Standard ISO4217 (currencies)\n- Standard E.164 (phone numbers)\n- Country Name Translations\n- VAT Rates\n- Address Formats\n- Timezones\n\n## Installation\n\n    go get github.com/pioz/countries\n\n## Usage\n\n### Identification Codes\n\n```go\nc := countries.Get(\"US\")\nfmt.Println(c.Number)\nfmt.Println(c.Alpha2)\nfmt.Println(c.Alpha3)\nfmt.Println(c.GEC)\n// Output:\n// 840\n// US\n// USA\n// US\n```\n\n### Names \u0026 Translations\n\n```go\nc := countries.Get(\"US\")\nfmt.Println(c.ISOLongName)\nfmt.Println(c.ISOShortName)\nfmt.Println(c.UnofficialNames)\nfmt.Println(c.Translations[\"en\"])\nfmt.Println(c.Translations[\"it\"])\nfmt.Println(c.Translations[\"de\"])\nfmt.Println(c.Nationality)\nfmt.Println(c.Capital)\nfmt.Println(c.EmojiFlag())\n// Output:\n// The United States of America\n// United States of America\n// [United States USA Vereinigte Staaten von Amerika États-Unis Estados Unidos アメリカ合衆国 Verenigde Staten Соединенные Штаты Америки]\n// United States\n// Stati Uniti\n// Vereinigte Staaten\n// American\n// Washington\n// 🇺🇸\n```\n\n### Subdivisions\n\n```go\nc := countries.Get(\"US\")\nca := c.Subdivision(\"CA\")\ntx := c.SubdivisionByName(\"Texas\")\nfmt.Println(len(c.Subdivisions))\nfmt.Println(ca.Name)\nfmt.Println(ca.Type)\nfmt.Println(ca.Translations[\"de\"])\nfmt.Println(ca.Geo.Latitude)\nfmt.Println(tx.Code)\n// Output:\n// 57\n// California\n// state\n// Kalifornien\n// 36.778261\n// TX\n```\n\n### Locations\n\n```go\nc := countries.Get(\"US\")\nfmt.Println(c.Geo.Latitude)\nfmt.Println(c.Geo.Longitude)\nfmt.Println(c.Region)\nfmt.Println(c.Subregion)\nfmt.Println(c.Continent)\nfmt.Println(c.WorldRegion)\n// Output:\n// 37.09024\n// -95.712891\n// Americas\n// Northern America\n// North America\n// AMER\n```\n\n### Boundary Boxes\n\n```go\nc := countries.Get(\"US\")\nfmt.Println(c.Geo.MinLatitude)\nfmt.Println(c.Geo.MaxLatitude)\nfmt.Println(c.Geo.MinLongitude)\nfmt.Println(c.Geo.MaxLongitude)\nfmt.Println(c.Geo.Bounds.Northeast.Lat)\nfmt.Println(c.Geo.Bounds.Northeast.Lng)\nfmt.Println(c.Geo.Bounds.Southwest.Lat)\nfmt.Println(c.Geo.Bounds.Southwest.Lng)\n// Output:\n// 18.91619\n// 71.3577635769\n// -171.791110603\n// -66.96466\n// 71.3577635769\n// -66.96466\n// 18.91619\n// -171.791110603\n```\n\n### Telephone Routing (E164)\n\n```go\nc := countries.Get(\"US\")\nfmt.Println(c.CountryCode)\nfmt.Println(c.NationalDestinationCodeLengths)\nfmt.Println(c.NationalNumberLengths)\nfmt.Println(c.InternationalPrefix)\nfmt.Println(c.NationalPrefix)\n// Output:\n// 1\n// [3]\n// [10]\n// 011\n// 1\n```\n\n### Timezones\n\n```go\nc := countries.Get(\"DE\")\nfmt.Println(c.Timezones)\n// Output: [Europe/Berlin Europe/Busingen]\n```\n\n### Formatted Addresses\n\n```go\nc := countries.Get(\"US\")\nfmt.Println(c.AddressFormat)\nfmt.Println(\"---\")\nfmt.Println(c.FormatAddress(\"John Smith\", \"1084 Nuzum Court\", \"14214\", \"Buffalo\", \"New York\"))\n// Output:\n// {{recipient}}\n// {{street}}\n// {{city}} {{region_short}} {{postalcode}}\n// {{country}}\n// ---\n// John Smith\n// 1084 Nuzum Court\n// Buffalo NY 14214\n// United States of America\n```\n\n### VAT Rates\n\n```go\nc := countries.Get(\"IE\")\nfmt.Println(c.VatRates.Standard)\nfmt.Println(c.VatRates.Reduced)\nfmt.Println(c.VatRates.SuperReduced)\nfmt.Println(c.VatRates.Parking)\n// Output:\n// 23\n// [9 13]\n// 4\n// 13\n```\n\n### European Union Membership\n\n```go\nc := countries.Get(\"IT\")\nfmt.Println(c.EUMember)\n// Output: true\n```\n\n### European Economic Area Membership\n\n```go\nc := countries.Get(\"FR\")\nfmt.Println(c.EEAMember)\n// Output: true\n```\n\n### European Single Market Membership\n\n```go\nc := countries.Get(\"CH\")\nfmt.Println(c.ESMMember)\n// Output: true\n```\n\n### GDPR Compliant\n\n```go\nc := countries.Get(\"IT\")\nfmt.Println(c.GDPRCompliant())\n// Output: true\n```\n\n### Country Finders\n\n```go\nallCountries := countries.All\ncountriesInEurope := countries.InRegion(\"Europe\")\ncountriesInSouthernAsia := countries.InSubregion(\"Southern Asia\")\ncountriesInEU := countries.InEU()\nfmt.Println(len(allCountries))\nfmt.Println(len(countriesInEurope))\nfmt.Println(len(countriesInSouthernAsia))\nfmt.Println(len(countriesInEU))\n// Output:\n// 249\n// 51\n// 9\n// 27\n```\n\nPlease refer to the [godoc](https://godoc.org/github.com/pioz/countries) for all country fields, available functions and more.\nFurthermore, tests are a good and helpful starting point.\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/pioz/countries/issues.\n\n## License\n\nThe package is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpioz%2Fcountries","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpioz%2Fcountries","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpioz%2Fcountries/lists"}