Skip to content

Latest commit

 

History

History
47 lines (40 loc) · 1.94 KB

README.md

File metadata and controls

47 lines (40 loc) · 1.94 KB

Test GoDoc

gopher-money

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

gopher-money - rates GoDoc

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()

gopher-money - money GoDoc

Provides functionality for using rates to convert between currencies

converter := money.NewConverter(rates)
rawValue, err := converter.Convert(fromCurrencyCode, toCurrencyCode, value)

gopher-money - format GoDoc

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)

TODO

  • Add more features to rates library to support more features of Open Exchange Rates