Library for convert currencies from applications written with Go. Required Go v1.14 or newer.
Install exchange-rates-go using Go Module by following command:
go get github.com/yusufthedragon/exchange-rates-go
Then you import it by following code:
import exchangerates "github.com/yusufthedragon/exchange-rates-go"
var currency, err = exchangerates.ConvertCurrency(&exchangerates.RequestParameter{
From: "USD",
To: "IDR",
Value: 2,
})
if err != nil {
panic(err.Error())
}
fmt.Printf("Converted Currency: %+v\n", currency)
var currencyLastYear, err = exchangerates.ConvertCurrency(&exchangerates.RequestParameter{
Date: time.Now().AddDate(-1, 0, 0),
From: "USD",
To: "IDR",
Value: 2,
})
if err != nil {
panic(err.Error())
}
fmt.Printf("Converted Currency Last Year: %+v\n", currencyLastYear)
You can run the test by following command:
go test -v
For any requests, bugs, or comments, please open an issue or submit a pull request.