I'm using Go structs to represent two structurally different XML documents. One XML document is the source of the data being processed, and the other XML document is the target that the source should map into.
I have both XML documents mapped out in Go structs already, and both know how to marshal/unmarshal an XML structure.
So currently I'm typing out each path in each struct, to map fields from the source, into fields in the target.
Is there a quicker way to perhaps initialize a new Target instance, using some sort of shorthand to ease the mapping of data? Keeping in mind these are complex nested structures, so a pattern I can follow "to the depths" would be excellent.
EDIT: Adding sample XML data structures
The Go structs that represent these XML structures are pretty much a one-to-one representation of the XML structure, where each level of nesting is a new struct type. The structs were generated programmatically and are quite spread out, so it would take excessive effort to represent the data structures here (I'm short on time).
SOURCE data file - reaches up to 8 nested elements deep. There can be multiple elements, each of which will generate a new separate "TARGET" instance.
<orders>
<order order=no="111222333">
<customer>
<customer-no>555444333</customer-no>
<customer-email>test@test.com</customer-email>
<billing-address>
<first-name>Test</first-name>
<last-name>User</last-name>
</billing-address>
</customer>
<product-lineitems>
<product-lineitem>
<product-id>SomeProductSku</product-id>
<product-name>SomeProductName</product-name>
<base-price>40.00</base-price>
<quantity>1</quantity>
</product-lineitem>
</product-lineitems>
</order>
</orders>
TARGET data file - reaches up to 10 nested elements deep
<OrderCreateRequest orderType="SALES" requestId="bcHcsiaagLwM6aaadnXz7ifXZL">
<Order customerOrderId="111222333" levelOfService="REGULAR">
<Customer customerId="555444333">
<Name>
<LastName>User</LastName>
<FirstName>Test</FirstName>
</Name>
<EmailAddress>test@test.com</EmailAddress>
</Customer>
<OrderItems>
<OrderItem id="item_0_1" webLineId="1">
<ItemId>SomeProductSku</ItemId>
<Quantity>1</Quantity>
<Description>
<Description>SomeProductName</Description>
</Description>
<Pricing>
<Merchandise>
<UnitPrice>40.00</UnitPrice>
</Merchandise>
</Pricing>
</OrderItem>
</OrderItems>
</Order>
</OrderCreateRequest>
EDIT 2: I'm also trying to solve for type mappings not matching up. Currently I'm casting each value type as I assign it, which makes me thing I'm really going about this the wrong way. The XML<->struct representations are already built, so if it's just a matter of me needing to somehow initialize the Target struct using something like map[string]{interface{}} or whatever, let me know. Been quite awhile since I last looked at Go, so I'm certain I'm missing some better solution here