Documentation ¶
Index ¶
Constants ¶
View Source
const (
USD = "USD"
)
Variables ¶
View Source
var ( API_URL = "https://api.privatbank.ua/p24api/pubinfo?exchange&coursid=11" ErrUSDRateNotFound = errors.New("USD rate not found") )
View Source
var FetchRate = func() (float64, error) { resp, err := http.Get(API_URL) if err != nil { return 0, fmt.Errorf("failed to make GET request: %w", err) } if resp.StatusCode != http.StatusOK { return 0, fmt.Errorf("received non-200 response code: %d", resp.StatusCode) } defer resp.Body.Close() body, err := io.ReadAll(resp.Body) if err != nil { return 0, fmt.Errorf("failed to read response body: %w", err) } return parseRates(body) }
Functions ¶
This section is empty.
Types ¶
Click to show internal directories.
Click to hide internal directories.