From a0c412db96094bff48ebaaf6d98e601b63e8e3fb Mon Sep 17 00:00:00 2001 From: Canh Nguyen Date: Wed, 30 Sep 2020 16:47:50 +0800 Subject: [PATCH] fix: Add test for marshalling a struct with empty interfaces --- sheriff.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sheriff.go b/sheriff.go index 56e5922..91666b5 100644 --- a/sheriff.go +++ b/sheriff.go @@ -52,6 +52,9 @@ type Marshaller interface { // In all other cases we can't derive the type in a meaningful way and is therefore an `interface{}`. func Marshal(options *Options, data interface{}) (interface{}, error) { v := reflect.ValueOf(data) + if !v.IsValid() { + return data, nil + } t := v.Type() // Initialise nestedGroupsMap,