A Go library for formatting currency values with custom symbols and formats.
- Format currency amounts with custom symbols and patterns
- Supports negative values
- Handles USD and MYR out of the box
- Easily extendable for other currencies
go get github.com/sun01822/currency_formatterpackage main
import (
"fmt"
"github.com/sun01822/currency_formatter/currency"
"github.com/sun01822/currency_formatter/types"
)
func main() {
value := currency.FormatCurrency(types.Formatter{
Amount: -1234567.89,
Currency: "MYR",
Format: "RM ###,###,###.##",
})
fmt.Println(value) // Output: -1,234,567.89RM
}Formats the currency amount using the provided formatter.
Amount(float64): The amount to formatCurrency(string): Currency code (e.g., "USD", "MYR")Format(string): Format string (e.g., "RM ###,###,###.##")
- USD
- MYR
Apache License 2.0