From 544c42ebae13c4f215a0722b4067d4adb715be65 Mon Sep 17 00:00:00 2001 From: Nick White Date: Tue, 14 May 2019 15:40:12 +0100 Subject: pgconf: Don't print NaN if a page has no lines, and show the percentage, rather than float, for easier comparison --- pgconf/main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pgconf/main.go b/pgconf/main.go index 1b70ecc..d254f42 100644 --- a/pgconf/main.go +++ b/pgconf/main.go @@ -37,11 +37,16 @@ func main() { } } + if len(lines) == 0 { + fmt.Printf("No lines found\n") + os.Exit(0) + } + var total float64 for _, l := range lines { total += l.Avgconf } avg := total / float64(len(lines)) - fmt.Printf("%0.2f\n", avg) + fmt.Printf("%0.0f\n", avg * 100) } -- cgit v1.2.1-24-ge1ad