Skip to content

Commit 24978b1

Browse files
Christianelliotchance
Christian
authored andcommitted
Fix panic if MarshalOptions is nil (#4)
1 parent 0fa3b04 commit 24978b1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

serialize.go

+5
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,11 @@ func MarshalStruct(input interface{}, options *MarshalOptions) ([]byte, error) {
204204
// Marshal is the canonical way to perform the equivalent of serialize() in PHP.
205205
// It can handle encoding scalar types, slices and maps.
206206
func Marshal(input interface{}, options *MarshalOptions) ([]byte, error) {
207+
208+
if options == nil {
209+
options = DefaultMarshalOptions()
210+
}
211+
207212
// []byte is a special case because all strings (binary and otherwise)
208213
// are handled as strings in PHP.
209214
if bytesToEncode, ok := input.([]byte); ok {

0 commit comments

Comments
 (0)