currency_wrapper

package module
v0.0.0-...-3d8f07d Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2021 License: MIT Imports: 2 Imported by: 0

README

Go Currency Wrapper

pipeline status Coverage Status

A Go version of exchangerates-wrapper. (A wrapper around exchange rate APIs)

Background

exchangeratesapi.io was a free service without any pricing for getting current exchanges rates of currencies from the European Central Bank. It seems like the developer behind that sold the site because overnight an API Key and pricing was added. (See https://github.com/exchangeratesapi/exchangeratesapi/issues/117)

One often mentioned alternative - ratesapi.io - is also currently down...

There are multiple free API services, which run a similar API. This lib is a wrapper which outputs an available API.

Why did I re-implement this in Go?

My first version in TypeScript was created because I needed a library which I can use in a existing TypeScript project. But now I need something similar for Go projects of mine.

Go has great benefits like it compiles to a single binary and it performs much faster.

Install

go get -u gitlab.com/cmiksche/go-currency-wrapper

Usage

Look at the tests for good examples.

E.g.:

import (
    "gitlab.com/cmiksche/go-currency-wrapper"
)

func example() {
    apiString := currency_wrapper.GetAPI([]string{"USD", "EUR"})
}

General Information

License: MIT

Author: Christoph Daniel Miksche

See also

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAPI

func GetAPI(currencies []string) string

Types

type API

type API struct {
	URL        string
	Currencies []string
}

func GetAllAPIWithCurrencies

func GetAllAPIWithCurrencies(currencies []string) []API

func GetAllAPIWithSymbols

func GetAllAPIWithSymbols() []API

type ExchangerateHostSymbols

type ExchangerateHostSymbols struct {
	Motd struct {
		Msg string `json:"msg,omitempty"`
		Url string `json:"url,omitempty"`
	} `json:"motd,omitempty"`
	Success bool `json:"success"`
	Symbols map[string]struct {
		Description string `json:"description,omitempty"`
		Code        string `json:"code,omitempty"`
	} `json:"symbols,omitempty"`
}

Jump to

Keyboard shortcuts

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