Skip to content

Commit

Permalink
encoding/xml: use struct literals with named fields
Browse files Browse the repository at this point in the history
  • Loading branch information
ydnar committed Oct 13, 2023
1 parent d206c51 commit 47c2972
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/encoding/xml/marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,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
}
Expand All @@ -590,7 +590,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 {
Expand Down

0 comments on commit 47c2972

Please sign in to comment.