فهرست منبع

Allow nil lists.

nicerobot 9 سال پیش
والد
کامیت
649c208455
1فایلهای تغییر یافته به همراه4 افزوده شده و 0 حذف شده
  1. 4 0
      marshal.go

+ 4 - 0
marshal.go

@@ -1143,6 +1143,10 @@ func marshalList(info TypeInfo, value interface{}) ([]byte, error) {
 		return nil, marshalErrorf("marshal: can not marshal non collection type into list")
 	}
 
+	if value == nil {
+		return nil, nil
+	}
+
 	rv := reflect.ValueOf(value)
 	t := rv.Type()
 	k := t.Kind()