From 427ca18985b85a3337f51b5b44b7ec15c31d85dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arturo=20Filast=C3=B2?= Date: Tue, 7 Jan 2020 16:44:11 +0200 Subject: [PATCH] Refactor pattern of ok !ok --- nettests/psiphon.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/nettests/psiphon.go b/nettests/psiphon.go index 228a7ba..fef9fe9 100644 --- a/nettests/psiphon.go +++ b/nettests/psiphon.go @@ -26,16 +26,19 @@ type PsiphonTestKeys struct { // GetTestKeys generates a summary for a test run func (h Psiphon) GetTestKeys(tk map[string]interface{}) (interface{}, error) { - var err error + var ( + err error + ok bool + ) testKeys := PsiphonTestKeys{IsAnomaly: false, Failure: ""} if tk["failure"] != nil { testKeys.IsAnomaly = true - testKeys.Failure, ok := tk["failure"].(string) + testKeys.Failure, ok = tk["failure"].(string) if !ok { err = errors.Wrap(err, "failure key invalid") } } - testKeys.BootstrapTime, ok := tk["bootstrap_time"].(float64) + testKeys.BootstrapTime, ok = tk["bootstrap_time"].(float64) if !ok { err = errors.Wrap(err, "bootstrap_time key invalid") }