MCPcopy Create free account
hub / github.com/XmirrorSecurity/OpenSCA-cli / defaultStart

Function defaultStart

opensca/sca/java/xml/marshal.go:659–677  ·  view source on GitHub ↗

defaultStart returns the default start element to use, given the reflect type, field info, and start template.

(typ reflect.Type, finfo *fieldInfo, startTemplate *StartElement)

Source from the content-addressed store, hash-verified

657// defaultStart returns the default start element to use,
658// given the reflect type, field info, and start template.
659func defaultStart(typ reflect.Type, finfo *fieldInfo, startTemplate *StartElement) StartElement {
660 var start StartElement
661 // Precedence for the XML element name is as above,
662 // except that we do not look inside structs for the first field.
663 if startTemplate != nil {
664 start.Name = startTemplate.Name
665 start.Attr = append(start.Attr, startTemplate.Attr...)
666 } else if finfo != nil && finfo.name != "" {
667 start.Name.Local = finfo.name
668 start.Name.Space = finfo.xmlns
669 } else if typ.Name() != "" {
670 start.Name.Local = typ.Name()
671 } else {
672 // Must be a pointer to a named type,
673 // since it has the Marshaler methods.
674 start.Name.Local = typ.Elem().Name()
675 }
676 return start
677}
678
679// marshalInterface marshals a Marshaler interface value.
680func (p *printer) marshalInterface(val Marshaler, start StartElement) error {

Callers 1

marshalValueMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected