go icon indicating copy to clipboard operation
go copied to clipboard

Prevent panic on self-referencing structs/map/slices during Marshal

Open tsuperis3112 opened this issue 1 year ago • 0 comments

This PR fixes a bug in Marshal where it would panic when attempting to serialize self-referencing structs or slices.

Previously, encountering these data structures would cause a panic, making it difficult to handle these situations gracefully. This change modifies Marshal to return an error instead, providing a more consistent and predictable way to handle serialization errors. This aligns the behavior with json.Marshal, which also returns an error when encountering self-referencing data structures.

This improvement enhances the robustness of the library and makes it easier to handle potential errors during serialization.

tsuperis3112 avatar Dec 31 '24 04:12 tsuperis3112