currency

package
v0.0.0-...-af36fad Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fetch

func Fetch(url string) ([]byte, error)

Fetch makes a GET request to the given resource url

func ParseBase

func ParseBase(data []byte) string

ParseBase retrieves base currency value from the decoded json response

func ParseRates

func ParseRates(data []byte) map[string]interface{}

ParseRates retrieves rates object from the decoded json response

Types

type Currency

type Currency struct {
	Rates map[string]interface{}
	Base  string
}

Currency holds our base currency and the exchange rates of other currencies against the base currency

func (*Currency) Convert

func (c *Currency) Convert(val float64, from string, to string) (rate float64, cnvtErr error)

Convert converts a value from one currency to another

Jump to

Keyboard shortcuts

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