A Go library for handling currency amounts, providing currency information, formatting, and parsing using CLDR data.
Currency is a Go library for handling currency amounts, providing currency information, and formatting amounts according to locale-specific rules. It solves the problem of accurate financial calculations and internationalization by implementing Fowler's Money pattern and leveraging CLDR data.
Go developers building financial applications, e-commerce platforms, or any software requiring precise currency arithmetic and international formatting.
Developers choose Currency for its correctness, ease of use, and performance—it uses a real decimal implementation to avoid floating-point errors, offers a clean API, and integrates seamlessly with databases like PostgreSQL.
Currency handling for Go.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses the cockroachdb/apd package to avoid floating-point errors, ensuring accurate financial calculations like multiplication and conversion without precision loss.
Filters CLDR locales from ~560 to ~370 and deduplicates by parent, reducing data to ~40kb while maintaining full formatting capabilities for all locales.
Supports PostgreSQL composite types natively via driver.Valuer and sql.Scanner, and provides wiki notes for MySQL, MariaDB, and SQLite integration.
Implements Fowler's Money pattern with an Amount struct, enabling safe arithmetic operations and comparison using go-cmp for equality checks.
Excludes localized currency names to save space, requiring frontend tools like Intl.DisplayNames or additional libraries for full display, which may complicate server-side rendering.
Relies on the third-party cockroachdb/apd package for decimal arithmetic, introducing potential versioning issues or maintenance overhead if the dependency changes.
Exclusively for Go, making it unsuitable for projects in other languages or those requiring a cross-platform currency handling solution.