Skip to content

Commit 0830d3e

Browse files
author
Brian Sutherland
committed
Parse strings to floats. fixes #15
1 parent 5085f2a commit 0830d3e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

postgres_exporter.go

+7
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,13 @@ func dbToFloat64(t interface{}) (float64, bool) {
323323
return math.NaN(), false
324324
}
325325
return result, true
326+
case string:
327+
result, err := strconv.ParseFloat(v, 64)
328+
if err != nil {
329+
log.Println("Could not parse string:", err)
330+
return math.NaN(), false
331+
}
332+
return result, true
326333
case nil:
327334
return math.NaN(), true
328335
default:

0 commit comments

Comments
 (0)