currency

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 28, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultCurrency = "USD"

DefaultCurrency is the currency code used when none is specified in configuration.

Variables

This section is empty.

Functions

func FormatCurrency

func FormatCurrency(amount float64, currencyCode string) string

FormatCurrency formats an amount with the appropriate currency symbol. The currencyCode is normalized to uppercase and looked up in the symbol map. If the currency code is empty or unknown, it defaults to USD ($).

Examples:

FormatCurrency(150.00, "USD") returns "$150.00"
FormatCurrency(99.99, "EUR") returns "€99.99"
FormatCurrency(1234.56, "GBP") returns "£1234.56"
FormatCurrency(100.00, "") returns "$100.00"
FormatCurrency(100.00, "UNKNOWN") returns "$100.00"

func GetSupportedCurrencies

func GetSupportedCurrencies() []string

GetSupportedCurrencies returns a sorted list of all supported currency codes. This is useful for documentation or validation purposes.

func GetSymbol

func GetSymbol(currencyCode string) string

GetSymbol returns the display symbol for the given currency code. The currency code is normalized to uppercase before lookup. If the currency code is not found, it returns the code itself.

Examples:

GetSymbol("USD") returns "$"
GetSymbol("eur") returns "€"
GetSymbol("UNKNOWN") returns "UNKNOWN"

func IsSupported

func IsSupported(currencyCode string) bool

IsSupported returns true if the given currency code is in the supported currencies map. The currency code is normalized to uppercase before checking.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL