Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
github.com/dmfed/cbrapi
Package cbrapi partially implements API of Central Bank of Russia. Implemented functions allow to quote currency rates at specified date or range of dates. See website of Central Bank of Russia for details.
Usage is quite simple (see below sample code). The only two points that need to be mentioned are as follows.
Methods which accept dates have signatures with interface{} type. These require either time.Time object or date in form of string formatted strictly as "DD/MM/YYYY". Supplying string formatted in a different way would result in a error.
ExchangeRate object implements Stringer, so if you care to only receive the float (the rate itself), use relevant field and do not Print/Sprint etc.
See package documentation at pkg.go.dev for details.
To use the library: go get github.com/dmfed/cbrapi
And here comes a working example:
import "https://github.com/dmfed/cbrapi/"
package main
import (
"fmt"
"time"
"github.com/dmfed/cbrapi"
)
func main() {
usd, err := cbrapi.New("USD")
if err != nil {
fmt.Println(err)
return
}
usdrate, err := usd.RateAtDate(time.Now()) // returns current exchange rate USD/RUB
fmt.Println(usdrate, err)
eurrate, _ := cbrapi.QuoteAtDate("EUR", "01/09/2020") // returns exchange rate of EUR at September 1st 2020
fmt.Println(eurrate)
usdrange, _ := usd.RateAtRangeDates("01/09/2020", "04/09/2020")
for _, item := range usdrange {
fmt.Println(item)
}
}
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.