{"id":16175766,"url":"https://github.com/alexferrari88/go-price-parser","last_synced_at":"2026-07-08T17:31:29.666Z","repository":{"id":57704290,"uuid":"497501548","full_name":"alexferrari88/go-price-parser","owner":"alexferrari88","description":"Price parser in Go","archived":false,"fork":false,"pushed_at":"2022-05-29T07:37:14.000Z","size":6,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-06T20:53:40.939Z","etag":null,"topics":["go","golang","parser","parsing","price-parser"],"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/alexferrari88.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-05-29T05:44:43.000Z","updated_at":"2023-11-05T20:10:50.000Z","dependencies_parsed_at":"2022-08-31T13:50:36.142Z","dependency_job_id":null,"html_url":"https://github.com/alexferrari88/go-price-parser","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexferrari88%2Fgo-price-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexferrari88%2Fgo-price-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexferrari88%2Fgo-price-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexferrari88%2Fgo-price-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexferrari88","download_url":"https://codeload.github.com/alexferrari88/go-price-parser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247640475,"owners_count":20971558,"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":["go","golang","parser","parsing","price-parser"],"created_at":"2024-10-10T04:46:13.524Z","updated_at":"2025-10-26T09:04:46.204Z","avatar_url":"https://github.com/alexferrari88.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go Price Parser\n\nDon't you find it frustrating that whenever you are trying to parse price from scraped data, you can never just use one simple regex and be done with it?\n\nWouldn't be great, right?\n\nEvery website (and country) deciding to now use a comma, now a dot, and why not a space?!\n\nWell, I was fed up with it and made this little library that just does one thing: **you feed it a string with a price, and it gives you back a nicely formatted int**.\n\nWhy an int, you might wonder?\n\nWell, that's easy to deal with and not get crazy with all those float shenanigans.\n\n## Features 🚀\n\n- Parses a \"dirty\" price string into an integer (e.g. \"42,069.23 USD\" =\u003e 4206923)\n- Returns values as either directly integer or as Price struct (allows some extra formatting features)\n\n## Installation 📦\n\nInstall it as usual with:\n\n```bash\n  go get github.com/alexferrari88/go-price-parser\n```\n\n## Usage/Examples 🔧\n\nYou can have the return values as either int or as the Price struct defined in this library\n\n### Return value as int\n\nThis is handy if you want to pipe the parsed price in a library such as [Money](https://github.com/Rhymond/go-money).\n\n```go\nscrapedPrice := \"42.99 USD\"\nprice, err := priceParser.IntFromString(scrapedPrice)\nif err != nill {\n    panic(err)\n}\n\nfmt.Println(price) // Output: 4299\n```\n\n### Return value as Price struct\n\nYou can use this if you want to keep the currency or for some formatting (see below).\n\n```go\nscrapedPrice := \"42.99 USD\"\nprice, err := priceParser.PriceFromString(scrapedPrice)\nif err != nill {\n    panic(err)\n}\n\nfmt.Println(price.Amount) // Output: 4299\n```\n\n### Other handy functions in the package\n\nIf you keep the result of the function as Price struct, you can also use the functions String() and Float().\n\n#### Examples\n\n```go\nscrapedPrice := \"42.99 USD\"\nprice, err := priceParser.PriceFromString(scrapedPrice)\nif err != nill {\n    panic(err)\n}\n\nfmt.Println(price.Amount.String()) // Output: \"42.99 USD\"\nfmt.Println(price.Amount.Float()) // Output: \"42.99\"\n```\n\n## To Do ✅\n\n- [ ] Implement currency detection\n- [ ] Add more documentation to the code\n- [ ] Create tests\n- [ ] Optimize code\n- [ ] Improve README.md\n\n## Acknowledgements 🤗\n\n- [hayj/SystemTools](https://github.com/hayj/SystemTools) for the inspiration for this package\n\n## License 📝\n\n[MIT](https://choosealicense.com/licenses/mit/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexferrari88%2Fgo-price-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexferrari88%2Fgo-price-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexferrari88%2Fgo-price-parser/lists"}