When attempting to marshal XML,for example, take a struct such a this:
type Example struct{
A int
B int
C func() int // Unmarshallable
}
C is unmarshallable, and that's fine with me; it should be ignored. However, the most that I've found is the omitempty attribute which isn't valid here. Every attempt to marshal the struct fails.
What I've considered is the following:
All of these are less than ideal, but 4) seems to be the most appealing. I'm open to any other suggestions about marshalling the struct, while ignoring C.
Either of these is less than ideal because it leaves
Setting the "xml" struct field tag to -
will prevent the field from being marshaled, as noted in the documentation:
The XML element for a struct contains marshaled elements for each of the exported fields of the struct, with these exceptions:
....
- a field with tag "-" is omitted.
type Example struct{
A int
B int
C func() int `xml:"-"`
}