bankiso icon indicating copy to clipboard operation
bankiso copied to clipboard

rules for omitempty on xml struct tags

Open ng2dev opened this issue 6 years ago • 1 comments

Hey

what paradigm do you follow to annotate the xml tags with ,omitempty

eg:

 type AccountAdditionalInformationRequestV02 struct {

        // Set of elements for the identification of the message and related references.
        References *iso20022.References3 `xml:"Refs"`

        // Identifies the business sender of the message, if it is not the account owner or account servicing financial institution.
        From *iso20022.OrganisationIdentification8 `xml:"Fr,omitempty"``

sometimes it is not supplied. Why is that? Can I change it to be more consistent? Namely to add omitempty to everything.

ng2dev avatar Jul 17 '19 15:07 ng2dev

I actually added an omitempty to kinda all the struct tags but it still does the xml.Unmarshal carrying the empty values into the struct in validate.go:169. The omitempty does not seem to have effect in any way.

ng2dev avatar Jul 17 '19 17:07 ng2dev