From 50dca153c8ae5f40319339bf3eabd8f72a30285d Mon Sep 17 00:00:00 2001 From: Rahul Gupta Date: Mon, 4 Dec 2023 18:47:22 +0530 Subject: [PATCH] fix: print results if not nil for rest CLI --- cmd/tools/rest/rest.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/cmd/tools/rest/rest.go b/cmd/tools/rest/rest.go index 3a2711b05..b5f2dc4e9 100644 --- a/cmd/tools/rest/rest.go +++ b/cmd/tools/rest/rest.go @@ -310,12 +310,14 @@ outer: } } - pretty, err := json.MarshalIndent(results, "", " ") - if err != nil { - stderr("error marshalling json %+v\n", err) - return + if results != nil { + pretty, err := json.MarshalIndent(results, "", " ") + if err != nil { + stderr("error marshalling json %+v\n", err) + return + } + fmt.Printf("%s\n", pretty) } - fmt.Printf("%s\n", pretty) } func GetPollerAndAddr(pName string) (*conf.Poller, string, error) {