Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/filiptubic/eurex
https://github.com/filiptubic/eurex
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/filiptubic/eurex
- Owner: filiptubic
- License: mit
- Created: 2022-03-26T15:56:59.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-03-27T19:48:06.000Z (almost 3 years ago)
- Last Synced: 2024-06-21T14:03:48.804Z (7 months ago)
- Language: Go
- Size: 44.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# eurex
Eurex is a simple money conversion library which converts value from one currency to another.
Rates which are applied are configurable and currently only supported rate source is from ECB ([European Central Bank](https://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist-90d.xml)).## Quickstart
### Install
Open terminal and invoke:
```
go get -u github.com/filiptubic/eurex
```
### Example
Convert 10 USD to CHF on 25. March 2022:
```
package mainimport (
"time""github.com/filiptubic/eurex"
"github.com/filiptubic/eurex/currency"
"github.com/sirupsen/logrus"
)func main() {
logger := eurex.DefaultLogger
logger.SetLevel(logrus.DebugLevel)
converter := eurex.DefaultConverter
date := time.Date(2022, time.March, 25, 0, 0, 0, 0, time.Local)value, err := converter.Convert(date, 10, currency.USD, currency.CHF)
if err != nil {
logger.Errorf("got error: %v", err)
}
logger.Info(value)
}
```
Outputs:
```
DEBU[0000] [GET] https://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist-90d.xml: code=200
INFO[0000] 9.277404108343935
```## Tests
Clone repo and invoke in project root:
```
go test -coverprofile=coverage.out ./... -v
```## Docs
Docs are available [here](https://pkg.go.dev/github.com/filiptubic/eurex).Docs are locally available by invoking `godoc` in project root and opening http://localhost:6060/pkg/github.com/filiptubic/eurex/ in browser.