1
0
mirror of https://github.com/golang/go synced 2024-11-22 04:24:39 -07:00

encoding/xml: use struct literals with named fields

This commit is contained in:
Randy Reddig 2023-05-05 11:19:35 -07:00 committed by Randy Reddig
parent d5764cf484
commit 67dbca9626
No known key found for this signature in database

View File

@ -582,7 +582,7 @@ func (p *printer) marshalValue(val reflect.Value, finfo *fieldInfo, startTemplat
continue
}
name := Name{finfo.xmlns, joinPrefixed(finfo.prefix, finfo.name)}
name := Name{Space: finfo.xmlns, Local: joinPrefixed(finfo.prefix, finfo.name)}
if err := p.marshalAttr(&start, name, fv); err != nil {
return err
}
@ -592,7 +592,7 @@ func (p *printer) marshalValue(val reflect.Value, finfo *fieldInfo, startTemplat
if tinfo.xmlname != nil && start.Name.Space == "" &&
tinfo.xmlname.xmlns == "" && tinfo.xmlname.name == "" &&
len(p.elements) != 0 && p.elements[len(p.elements)-1].xmlns != "" {
start.Attr = append(start.Attr, Attr{Name{"", xmlnsPrefix}, ""})
start.Attr = append(start.Attr, Attr{Name{Space: "", Local: xmlnsPrefix}, ""})
}
if err := p.writeStart(&start); err != nil {