finds.dev

leekchan/accounting

money and currency formatting for golang

View on GitHub

★ 910GoMITupdated Jul 2022

// the take

A Go library for formatting numbers as money values — currency symbols, thousand/decimal separators, locale presets for 181 currencies. Essentially a port of accounting.js. Useful when you need to display monetary values in a Go backend or CLI without pulling in a full money library.

Supports `big.Rat`, `big.Float`, and `shopspring/decimal` so you can avoid float64 precision issues in financial code. Type-specific methods (FormatMoneyInt, FormatMoneyBigRat, etc.) let you skip reflection overhead when you know your type. The format string system (`%s %v`, `%s (%v)`) handles negative and zero display without conditional logic at the call site. Ships with a `LocaleInfo` map covering 181 currencies so you don't have to hardcode separators for EUR, CHF, JPY, etc.

Abandoned since 2022 — the `15` suffix on files (`accounting15.go`) is a Go 1.5 compatibility relic that was never cleaned up and signals low maintenance investment. No arithmetic: this is display-only, so you still need `shopspring/decimal` or similar for actual money math, making this a narrow dependency. `UnformatNumber` is simplistic — it strips formatting by pattern-matching rather than parsing locale-aware input, so round-tripping non-USD formats is fragile. No support for `decimal.Decimal` directly in `FormatMoney` via reflection despite having a dedicated `FormatMoneyDecimal` method, which means `FormatMoney(myDecimal)` silently falls through to an unhandled type.

We read the README, the directory tree and a key source file in June 2026. Nobody pays to be listed. How we judge →

// at a glance

Stars
910
Forks
73
Language
Go
License
MIT
Last commit
28 Jul 2022

// nearby

If accounting isn't quite it.

All repos →