Documentation
¶
Overview ¶
Package ecbrates 0.3.0 This package helps parse the ECB exchange rates and use it for an applications
Example 1:
package main
import (
"fmt"
"log"
"github.com/openprovider/ecbrates"
)
func main() {
r, err := ecbrates.New()
if err != nil {
log.Fatal("Error: ", err)
}
// Case 1: get dollar rate relative to euro
if value, ok := r.Rate[ecbrates.USD].(string); ok {
fmt.Println("Exchange rate", r.Date, ": EUR 1 -> USD", value)
}
// Case 2: convert of 100 euros to dollars
if value, err := r.Convert(100, ecbrates.EUR, ecbrates.USD); err == nil {
fmt.Println("Exchange rate", r.Date, ": EUR 100.0 -> USD", value)
}
}
Example 2:
package main
import (
"fmt"
"log"
"github.com/openprovider/ecbrates"
)
func main() {
rates, err := ecbrates.Load() // load last 90 days
// rates, err := ecbrates.LoadAll() // <- load ALL historical data, lots of data!
if err != nil {
log.Fatal("Error: ", err)
}
// Show history of exchange rates for EUR -> USD
for _, r := range rates {
if value, ok := r.Rate[ecbrates.USD].(string); ok {
fmt.Println("Exchange rate", r.Date, ": EUR 1 -> USD", value)
}
}
}
The European Central Bank exchange rates
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Currencies = []Currency{ AUD, BGN, BRL, CAD, CHF, CNY, CZK, DKK, EUR, GBP, HKD, HRK, HUF, IDR, ILS, INR, JPY, KRW, LTL, MXN, MYR, NOK, NZD, PHP, PLN, RON, RUB, SEK, SGD, THB, TRY, USD, ZAR, CYP, EEK, ISK, LVL, MTL, SIT, SKK, ROL, TRL, }
Currencies are valid values for currency
Functions ¶
This section is empty.
Types ¶
type Currency ¶
type Currency string
Currency type as a link to string
const ( AUD Currency = "AUD" // Australian Dollar (A$) BGN Currency = "BGN" // Bulgarian Lev (BGN) BRL Currency = "BRL" // Brazilian Real (R$) CAD Currency = "CAD" // Canadian Dollar (CA$) CHF Currency = "CHF" // Swiss Franc (CHF) CNY Currency = "CNY" // Chinese Yuan (CN¥) CZK Currency = "CZK" // Czech Republic Koruna (CZK) DKK Currency = "DKK" // Danish Krone (DKK) EUR Currency = "EUR" // Euro (€) GBP Currency = "GBP" // British Pound Sterling (£) HKD Currency = "HKD" // Hong Kong Dollar (HK$) HRK Currency = "HRK" // Croatian Kuna (HRK) HUF Currency = "HUF" // Hungarian Forint (HUF) IDR Currency = "IDR" // Indonesian Rupiah (IDR) ILS Currency = "ILS" // Israeli New Sheqel (₪) INR Currency = "INR" // Indian Rupee (Rs.) JPY Currency = "JPY" // Japanese Yen (¥) KRW Currency = "KRW" // South Korean Won (₩) LTL Currency = "LTL" // Lithuanian Litas (LTL) MXN Currency = "MXN" // Mexican Peso (MX$) MYR Currency = "MYR" // Malaysian Ringgit (MYR) NOK Currency = "NOK" // Norwegian Krone (NOK) NZD Currency = "NZD" // New Zealand Dollar (NZ$) PHP Currency = "PHP" // Philippine Peso (Php) PLN Currency = "PLN" // Polish Zloty (PLN) RON Currency = "RON" // Romanian Leu (RON) RUB Currency = "RUB" // Russian Ruble (RUB) SEK Currency = "SEK" // Swedish Krona (SEK) SGD Currency = "SGD" // Singapore Dollar (SGD) THB Currency = "THB" // Thai Baht (฿) TRY Currency = "TRY" // Turkish Lira (TRY) USD Currency = "USD" // US Dollar ($) ZAR Currency = "ZAR" // South African Rand (ZAR) // Historical currencies CYP Currency = "CYP" EEK Currency = "EEK" ISK Currency = "ISK" LVL Currency = "LVL" MTL Currency = "MTL" SIT Currency = "SIT" SKK Currency = "SKK" ROL Currency = "ROL" TRL Currency = "TRL" )
List of all supported currencies
type Rates ¶
Rates represent date and currency exchange rates
Click to show internal directories.
Click to hide internal directories.