From fe3bab8e8a2b2448827c3b703b1396cf76355fde Mon Sep 17 00:00:00 2001 From: lnu Date: Mon, 13 Dec 2021 12:45:05 +0100 Subject: [PATCH] fix(yaml): try int parsing before fallback json and yaml returns 2 different types float64 vs int --- src/properties.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/properties.go b/src/properties.go index 596cb5e8..4a56277f 100644 --- a/src/properties.go +++ b/src/properties.go @@ -89,12 +89,17 @@ func (p properties) getFloat64(property Property, defaultValue float64) float64 return defaultValue } - floatValue, ok := val.(float64) + if floatValue, ok := val.(float64); ok { + return floatValue + } + + // config parser parses an int + intValue, ok := val.(int) if !ok { return defaultValue } - return floatValue + return float64(intValue) } func (p properties) getInt(property Property, defaultValue int) int { @@ -107,7 +112,7 @@ func (p properties) getInt(property Property, defaultValue int) int { return intValue } - // json parses a float + // config parser parses a float intValue, ok := val.(float64) if !ok { return defaultValue