exchangerate

package module
v0.0.0-...-b28a347 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2021 License: MIT Imports: 6 Imported by: 0

README

 _                              _             
|_     _ |_   _. ._   _   _    |_)  _. _|_  _ 
|_ >< (_ | | (_| | | (_| (/_   | \ (_|  |_ (/_
                      _|    

Build Status Go Report Card GoDoc

A simple command-line tool to query exchange rate.

Installation

Homebrew
brew tap timothyye/tap
brew install timothyye/tap/exchangerate
Using Go
go get github.com/TimothyYe/exchangerate/cmd/er
Manual Installation

Download it from releases and extact it to /usr/bin or your PATH directory.

Get API Key

Your .er file may looks like:

→ cat ~/.er 
15d684b456848e2da877

Usage

% er -h

Exchange Rate V1.2
https://github.com/TimothyYe/exchangerate

NAME:
   Exchange Rate - A simple command-line tool to query exchange rate

USAGE:
   er [from currency] [amount] [to currency]

VERSION:
   1.2

EXAMPLES:
  er USD               Query USD and show exchange rate for common used currencies.  
  er USD 40.98         Query USD with amount 40.98, and show the equal amount of other currencies.  
  er USD 12 CNY,JPY    Query USD with amount 12 and show the equal amount of specified currencies.  

GLOBAL OPTIONS:
   --help, -h     show help
   --version, -v  print the version

Licence

MIT License

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Query

func Query(apiKey, from string, amount float32, to []string) map[string]string

Query exchange rates for multiple currencies

Types

type RateHelper

type RateHelper struct {
	APIKey       string
	Amount       float32
	FromCurrency string
	ToCurrency   []string
	Result       map[string]string
	// contains filtered or unexported fields
}

RateHelper struct definition

func NewRateHelper

func NewRateHelper() *RateHelper

NewRateHelper creates and return a new rate helper struct

func (*RateHelper) Query

func (helper *RateHelper) Query()

Query function, queries different exchange rates and return the results

func (*RateHelper) SaveResult

func (helper *RateHelper) SaveResult(key, value string)

SaveResult saves rate into internal map

Directories

Path Synopsis
cmd
er

Jump to

Keyboard shortcuts

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