Dear community, how can we XML marshal a struct field depending on the value of another struct field in the same struct?
Playground Example: https://go.dev/play/p/vfRB-GfzZ54 My approaches so far: - Use a custom type for the Feature field and implement xml.Marshaler. However MarshalXML has no access to other fields, so I might need some sort of "closure", not sure how to put that together - Implement xml.Marshaler for the entire struct - due to the number of fields included in the real struct (> 100), I guess this would be a lot of work.. - Use separate types for each "ItemType" - this replicates a lot of work because most struct fields are needed for both ItemType values I hope someone with more experience can give me some hints or tips. Thank you and all the best, Steffen -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/1b6e5b94-b219-4ea1-a20a-40248d1d65a5n%40googlegroups.com.