go-currency

command module
v0.0.0-...-7257806 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2016 License: Apache-2.0 Imports: 8 Imported by: 0

README

go-currency

Build Status Go Report Card

go-currency is a currency exchange rate converter service written in Go. By default uses Fixer.io as exchange rate provider.

Online version (heroku)

Heroku - go-currency

Install & Run

This project assumes that you are working in a standard Go workspace, as described in http://golang.org/doc/code.html.

Bash
# Go to your $GOPATH
$ cd $GOPATH

# Download and build
$ go get github.com/floreks/go-currency

# Run it
$ ./bin/go-currency --port <OPTIONAL_PORT>
Docker

Container can be stopped using CTRL+C.

Building own image
# Go to your $GOPATH
$ cd $GOPATH

# Download and build
$ go get github.com/floreks/go-currency

$ cd $GOPATH/src/github.com/floreks/go-currency

# Build docker image
$ docker build -t go-currency .

# Run our service
$ docker run -p 8080:8080 go-currency
DockerHub image

Check it out on docker hub: go-currency

In order to run it just type in your console:

$ docker run -p 8080:8080 floreks/go-currency

Usage

Let's assume that the application is running on localhost:8080. Service can produce XML/JSON output based on request header.

XML output

Exchange rates for 200 SEK

curl -H "Accept: application/xml, */*" "http://localhost:8080/convert?amount=200&currency=SEK"
JSON output

Exchange rates for 200 SEK

curl "http://localhost:8080/convert?amount=200&currency=SEK"
Offline provider

Additionally if Fixer.io is offline we can fallback to local provider that uses exchange rates from 31.10.2016. It supports only 3 base currencies: EUR, PLN, USD.

curl "http://localhost:8080/convert?amount=200&currency=PLN&provider=local"

Running tests

Go to your project directory and run:

$ go test ./...

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
provider
service

Jump to

Keyboard shortcuts

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