You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I run into the issue where I wanted to omitempty a non-pointer struct. I couldn't make it happen properly so I think about a solution. So this is the code running I guess when there is the omitempty tag on the field. What if it would check for an extra interface implementation where we can flexibly determine when we consider a non-pointer struct as empty?
So use-case in this playground. It seems that the empty struct marshalled into the JSON. But if the Go has an interface like below I can implement this and the linked source can look for that implementation. If no any implementation than go with the default.
type Something interface {
IsEmpty() bool
}
The text was updated successfully, but these errors were encountered:
Questions unrelated.
I run into the issue where I wanted to omitempty a non-pointer struct. I couldn't make it happen properly so I think about a solution. So this is the code running I guess when there is the omitempty tag on the field. What if it would check for an extra interface implementation where we can flexibly determine when we consider a non-pointer struct as empty?
So use-case in this playground. It seems that the empty struct marshalled into the JSON. But if the Go has an interface like below I can implement this and the linked source can look for that implementation. If no any implementation than go with the default.
The text was updated successfully, but these errors were encountered: