A simple CLI tool written in Go for calculating exchange rates using foreign exchange reference rates published by the European Central Bank.
go install github.com/timorunge/currencyconverter/cmd/currencyconverter@latestDownload pre-built binaries for your platform from the releases page.
git clone https://github.com/timorunge/currencyconverter.git
cd currencyconverter
make buildConvert 100 EUR to USD:
currencyconverter --amount 100 --from EUR --to USD100 EUR ≈ 111.51 USD (2019-07-31, ECB)
Convert for a specific date:
currencyconverter --amount 500 --from USD --to GBP --date 2019-07-31Swap currencies with --reverse:
currencyconverter --from EUR --to USD --reverseGet JSON output:
currencyconverter --amount 100 --from EUR --to USD --json{"amount":100,"from":"EUR","to":"USD","result":111.51,"date":"2019-07-31","source":"ECB"}currencyconverter - Exchange rate calculator using ECB reference rates
Usage:
currencyconverter [OPTIONS]
Options:
-f, --from string Currency to use as base (default "EUR")
-t, --to string Currency to convert to (default "USD")
-a, --amount float Amount to calculate (default 1)
-d, --date string Date for the calculation (latest|YYYY-MM-DD) (default "latest")
-r, --reverse Swap from and to values
--json Output result as JSON
--no-cache Disable caching
-h, --help Show this help message
--version Show the version of currencyconverter
--supported-currencies Show a list with all supported currencies
AUD, BGN, BRL, CAD, CHF, CNY, CZK, DKK, EUR, GBP, HKD, HUF, IDR, ILS, INR, ISK, JPY, KRW, MXN, MYR, NOK, NZD, PHP, PLN, RON, SEK, SGD, THB, TRY, USD, ZAR
Run currencyconverter --supported-currencies for the full list.
Exchange rates are cached locally as JSON files in the OS temp
directory. Latest rates are cached until the top of the next hour,
keeping network calls low while staying current with ECB updates.
Historical dates are cached indefinitely since their rates never
change. Disable caching with --no-cache.
make help # Show all available targets
make check # Run all quality gates (fmt, tidy, vet, lint, test)
make lint # Run golangci-lint
make test # Run tests with race detector
make build # Build static binary