Skip to content

Open exchange rates wrapper for go, with conversion functionality

License

Notifications You must be signed in to change notification settings

aaron-hardin/gopher-money

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Open exchange rates wrapper for go, with conversion functionality

Resources

License

Stars

Watchers

Forks

Packages

No packages published