Is your feature request related to a problem? Please describe.
When implementing JSON or YAML serialization in Go, developers sometimes use incorrect receiver types for MarshalJSON, MarshalYAML, UnmarshalJSON, and UnmarshalYAML methods. Using a pointer receiver on a Marshal method means marshaling won't work when the value is passed by value (e.g., in a slice or map). Using a value receiver on an Unmarshal method means modifications to the receiver are lost. These bugs are subtle and easy to miss in code review.
Describe the solution you'd like
A new marshal-receiver lint rule that flags:
- MarshalJSON / MarshalYAML methods using a pointer receiver (should use value receiver)
- UnmarshalJSON / UnmarshalYAML methods using a value receiver (should use pointer receiver)
Describe alternatives you've considered
Manual code review and documentation guidelines.
Additional context
N/A
Is your feature request related to a problem? Please describe.
When implementing JSON or YAML serialization in Go, developers sometimes use incorrect receiver types for MarshalJSON, MarshalYAML, UnmarshalJSON, and UnmarshalYAML methods. Using a pointer receiver on a Marshal method means marshaling won't work when the value is passed by value (e.g., in a slice or map). Using a value receiver on an Unmarshal method means modifications to the receiver are lost. These bugs are subtle and easy to miss in code review.
Describe the solution you'd like
A new marshal-receiver lint rule that flags:
Describe alternatives you've considered
Manual code review and documentation guidelines.
Additional context
N/A