exchangeRate

package
v1.15.23 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Url = "https://api.apilayer.com"
)

Variables

This section is empty.

Functions

func GetExchangeRete

func GetExchangeRete(form, to, access string, amount float64) (float64, error)

Types

type Cache added in v1.14.18

type Cache struct {
	// contains filtered or unexported fields
}

Cache stores the most recently fetched exchange rate safely for concurrent readers. It is shared by the exchange-rate refresh task and checkout flows.

func NewCache added in v1.14.18

func NewCache(rate float64) *Cache

NewCache creates a cache with the supplied initial rate.

func (*Cache) Get added in v1.14.18

func (c *Cache) Get() float64

Get returns the cached exchange rate.

func (*Cache) Set added in v1.14.18

func (c *Cache) Set(rate float64)

Set replaces the cached exchange rate.

type Response

type Response struct {
	Success bool   `json:"success"`
	Terms   string `json:"terms"`
	Privacy string `json:"privacy"`
	Query   struct {
		From   string  `json:"from"`
		To     string  `json:"to"`
		Amount float64 `json:"amount"`
	} `json:"query"`
	Info struct {
		Timestamp int64   `json:"timestamp"`
		Quote     float64 `json:"quote"`
	} `json:"info"`
	Result float64 `json:"result"`
}

Jump to

Keyboard shortcuts

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