Open droyo opened 6 years ago
I really like the fact that generated code uses basic types like time.Time
and []byte
(for base64Binary
) rather than exporting custom types, and would like to keep that property, if feasible. The most obvious way forward, then, is to add plural versions of all the "helper types":
type xsdDateTimeSlice []time.Time
type xsdBase64BinarySlice [][]byte
The accompanying methods would then look very similar to their scalar versions (see the principle here: https://play.golang.org/p/f715VAnArD)
Consider the element declaration below (note the "maxOccurs" attribute)
In Go, the ideal declaration for this type would be []time.Time. For scalar types, we can get away with converting a
*time.Time
to an*xsdDateTime
, a private type that we can attachMarshalXML/UnmarshalXML
methods to. This doesn't work with slice types: https://play.golang.org/p/ZAOS7gzcUk .Currently,
xsdgen
doesn't work at all for this scenario; it will generate code that tries to convert a*[]time.Time
to an*xsdDateTime
, which fails to compile.