From 898661f983c7a5627adcf714672eb40a5a3228ec Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Mon, 25 Jul 2016 15:39:55 -0400 Subject: [PATCH] check: omitempty rather than `null` When using `-result-format=json` flag, just show populated fields. Before: ```bash $ gomtree -result-format=json -p ./bin -f ./bin.mtree {"failures":[{"path":"gomtree","keyword":"size","expected":"2646101","got":"2930231"}],"Missing":null,"Extra":null} ``` After: ```bash $ gomtree -result-format=json -p ./bin -f ./bin.mtree {"failures":[{"path":"gomtree","keyword":"size","expected":"2646101","got":"2930231"}]} ``` Signed-off-by: Vincent Batts --- check.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/check.go b/check.go index a565251..2b72344 100644 --- a/check.go +++ b/check.go @@ -11,8 +11,8 @@ import ( type Result struct { // list of any failures in the Check Failures []Failure `json:"failures"` - Missing []Entry - Extra []Entry + Missing []Entry `json:"missing,omitempty"` + Extra []Entry `json:"extra,omitempty"` } // Failure of a particular keyword for a path