cbrf

package module
v0.0.0-...-7f1214a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2024 License: MIT Imports: 3 Imported by: 0

README

Получение и конвертация курсов валют ЦБ РФ на дату

Библиотека предназаначена для получения курсов валют ЦБ РФ и конвртации стоимости валют на заданную дату.

Установка

go get github.com/ivangurin/cbrf-go 

Пример использования

ctx := context.Background()
now := time.Now()

// Получение курса валюты на дату
exchangeRate, err := cbrf.GetExchangeRate(ctx, model.CurrencyUSD, now)

if err != nil {
    log.Fatal(err)
}

fmt.Printf("Текущий курс USD: %.2f рублей\n", exchangeRate)

// Конвертация 100 USD в EUR на дату
valueUSD := float64(100)
valueEUR, err := cbrf.Convert(ctx, model.CurrencyUSD, model.CurrencyEUR, valueUSD, now)

if err != nil {
    log.Fatal(err)
}

fmt.Printf("Стоимость %.2f USD равна %.2f EUR\n", valueUSD, valueEUR)

Лицензия

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Convert

func Convert(ctx context.Context, from string, to string, value float64, date time.Time) (float64, error)

func GetExchangeRate

func GetExchangeRate(ctx context.Context, currencyID string, date time.Time) (float64, error)

Types

This section is empty.

Directories

Path Synopsis
internal
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL