Command line utility for all things money
gopher-money convert USD JPY 44.3
> 4679.36746875
gopher-money round JPY 44.3
> 44
gopher-money format USD 44.3
> $44.30
Install using the following command
go get github.com/aaron-hardin/gopher-money
Wrapper around Open Exchange Rates to provide a convenient way to get current exchange rates
client := rates.NewApiClient(apiKey)
// rates is map[string]float64
// mapping currency code to current exchange rate
rates, err := client.GetRates()
Provides functionality for using rates to convert between currencies
converter := money.NewConverter(rates)
rawValue, err := converter.Convert(fromCurrencyCode, toCurrencyCode, value)
Provides functionality for formatting currencies, allows converting to correct precision as well as formatting to string with symbol
When providing a custom format string, %v is used for the value and %s is used for the currency symbol
roundedValue, err := format.Round(currencyCode, value)
displayValue, err := format.Format(currencyCode, value)
displayValue, err = format.FormatAs(currencyCode, value, customFormat)
- Add more features to rates library to support more features of Open Exchange Rates