From 4b57147101693f9dc9163535e391102800dd1e8d Mon Sep 17 00:00:00 2001 From: stevemeier Date: Mon, 5 Apr 2021 18:30:28 +0200 Subject: [PATCH] Implemented Issue #16: Status should be initialized as UNKNOWN instead of OK --- check.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/check.go b/check.go index 860d776..8b67277 100644 --- a/check.go +++ b/check.go @@ -48,6 +48,7 @@ type CheckOptions struct { // NewCheck returns an empty Check object. func NewCheck() *Check { c := new(Check) + c.status = 3 // initialize as UNKNOWN, 0 (default) is OK c.statusPolicy = NewDefaultStatusPolicy() return c } @@ -71,7 +72,8 @@ func (c *Check) AddResult(status Status, message string) { result.message = message c.results = append(c.results, result) - if (*c.statusPolicy)[result.status] > (*c.statusPolicy)[c.status] { + if (*c.statusPolicy)[result.status] > (*c.statusPolicy)[c.status] || + c.status == 3 { // allow trasition from UNKNOWN state to any c.status = result.status } }