mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
encoding/xml: improve package based on the suggestions from metalinter
Existing code in encoding/xml packages contains code which breaks various linter rules (comments, constant and variable naming, variable shadowing, etc). Fixes #21578 Change-Id: Id4bd9a9be6d5728ce88fb6efe33030ef943c078c Reviewed-on: https://go-review.googlesource.com/58210 Reviewed-by: Sam Whited <sam@samwhited.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Sam Whited <sam@samwhited.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
77b4beba2f
commit
6e9e9dfa46
8 changed files with 103 additions and 94 deletions
|
|
@ -16,10 +16,11 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
// A generic XML header suitable for use with the output of Marshal.
|
||||
// Header is a generic XML header suitable for use with the output of Marshal.
|
||||
// This is not automatically added to any output of this package,
|
||||
// it is provided as a convenience.
|
||||
Header = `<?xml version="1.0" encoding="UTF-8"?>` + "\n"
|
||||
Header = `<?xml version="1.0" encoding="UTF-8"?>` + "\n"
|
||||
xmlNamespacePrefix = "xml"
|
||||
)
|
||||
|
||||
// Marshal returns the XML encoding of v.
|
||||
|
|
@ -320,7 +321,7 @@ func (p *printer) createAttrPrefix(url string) string {
|
|||
// (The "http://www.w3.org/2000/xmlns/" name space is also predefined as "xmlns",
|
||||
// but users should not be trying to use that one directly - that's our job.)
|
||||
if url == xmlURL {
|
||||
return "xml"
|
||||
return xmlNamespacePrefix
|
||||
}
|
||||
|
||||
// Need to define a new name space.
|
||||
|
|
@ -1011,7 +1012,7 @@ func (s *parentStack) push(parents []string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// A MarshalXMLError is returned when Marshal encounters a type
|
||||
// UnsupportedTypeError is returned when Marshal encounters a type
|
||||
// that cannot be converted into XML.
|
||||
type UnsupportedTypeError struct {
|
||||
Type reflect.Type
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue