From 56e3cbe61e3f0475e64d5faf588270cccf9bcd26 Mon Sep 17 00:00:00 2001 From: Canh Nguyen Date: Wed, 30 Sep 2020 16:47:50 +0800 Subject: [PATCH] fix: Marshal empty interface --- 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,