From 6cdd6e01d1dafa39697510f3136b588001ff8bd5 Mon Sep 17 00:00:00 2001 From: Adrian Gallagher Date: Sun, 22 Mar 2015 18:14:03 +1100 Subject: [PATCH] Added default conversion currencies if only one base currency is loaded. --- currency.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/currency.go b/currency.go index f3b84416..80cda4be 100644 --- a/currency.go +++ b/currency.go @@ -38,6 +38,7 @@ type YahooJSONResponse struct { const ( YAHOO_YQL_URL = "http://query.yahooapis.com/v1/public/yql" YAHOO_DATABASE = "store://datatables.org/alltableswithkeys" + DEFAULT_CURRENCIES = "USD,AUD,EUR,CNY" ) @@ -52,8 +53,16 @@ func RetrieveConfigCurrencyPairs(config Config) (error) { currencyPairs := "" for _, exchange := range config.Exchanges { if (exchange.Enabled) { - result := strings.Split(exchange.BaseCurrencies, ",") - + var result []string + if strings.Contains(exchange.BaseCurrencies, ",") { + result = strings.Split(exchange.BaseCurrencies, ",") + } else { + if strings.Contains(DEFAULT_CURRENCIES, exchange.BaseCurrencies) { + result = strings.Split(DEFAULT_CURRENCIES, ",") + } else { + result = strings.Split(exchange.BaseCurrencies + "," + DEFAULT_CURRENCIES, ",") + } + } for _, s := range result { if (!strings.Contains(currencyPairs, s)) { currencyPairs += s + ","