summaryrefslogtreecommitdiff
path: root/libgo/go/encoding/xml/marshal.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/encoding/xml/marshal.go')
-rw-r--r--libgo/go/encoding/xml/marshal.go25
1 files changed, 12 insertions, 13 deletions
diff --git a/libgo/go/encoding/xml/marshal.go b/libgo/go/encoding/xml/marshal.go
index 8ebd693030e..abb078ce270 100644
--- a/libgo/go/encoding/xml/marshal.go
+++ b/libgo/go/encoding/xml/marshal.go
@@ -26,14 +26,14 @@ const (
//
// Marshal handles an array or slice by marshalling each of the elements.
// Marshal handles a pointer by marshalling the value it points at or, if the
-// pointer is nil, by writing nothing. Marshal handles an interface value by
+// pointer is nil, by writing nothing. Marshal handles an interface value by
// marshalling the value it contains or, if the interface value is nil, by
-// writing nothing. Marshal handles all other data by writing one or more XML
+// writing nothing. Marshal handles all other data by writing one or more XML
// elements containing the data.
//
// The name for the XML elements is taken from, in order of preference:
// - the tag on the XMLName field, if the data is a struct
-// - the value of the XMLName field of type xml.Name
+// - the value of the XMLName field of type Name
// - the tag of the struct field used to obtain the data
// - the name of the struct field used to obtain the data
// - the name of the marshalled type
@@ -63,7 +63,7 @@ const (
// value were part of the outer struct.
//
// If a field uses a tag "a>b>c", then the element c will be nested inside
-// parent elements a and b. Fields that appear next to each other that name
+// parent elements a and b. Fields that appear next to each other that name
// the same parent will be enclosed in one XML element.
//
// See MarshalIndent for an example.
@@ -175,10 +175,9 @@ func (enc *Encoder) EncodeElement(v interface{}, start StartElement) error {
}
var (
- begComment = []byte("<!--")
- endComment = []byte("-->")
- endProcInst = []byte("?>")
- endDirective = []byte(">")
+ begComment = []byte("<!--")
+ endComment = []byte("-->")
+ endProcInst = []byte("?>")
)
// EncodeToken writes the given XML token to the stream.
@@ -217,7 +216,7 @@ func (enc *Encoder) EncodeToken(t Token) error {
return p.cachedWriteError()
case ProcInst:
// First token to be encoded which is also a ProcInst with target of xml
- // is the xml declaration. The only ProcInst where target of xml is allowed.
+ // is the xml declaration. The only ProcInst where target of xml is allowed.
if t.Target == "xml" && p.Buffered() != 0 {
return fmt.Errorf("xml: EncodeToken of ProcInst xml target only valid for xml declaration, first token encoded")
}
@@ -850,14 +849,14 @@ func (p *printer) marshalStruct(tinfo *typeInfo, val reflect.Value) error {
switch k {
case reflect.String:
s := vf.String()
- dashDash = strings.Index(s, "--") >= 0
+ dashDash = strings.Contains(s, "--")
dashLast = s[len(s)-1] == '-'
if !dashDash {
p.WriteString(s)
}
case reflect.Slice:
b := vf.Bytes()
- dashDash = bytes.Index(b, ddBytes) >= 0
+ dashDash = bytes.Contains(b, ddBytes)
dashLast = b[len(b)-1] == '-'
if !dashDash {
p.Write(b)
@@ -949,8 +948,8 @@ type parentStack struct {
}
// trim updates the XML context to match the longest common prefix of the stack
-// and the given parents. A closing tag will be written for every parent
-// popped. Passing a zero slice or nil will close all the elements.
+// and the given parents. A closing tag will be written for every parent
+// popped. Passing a zero slice or nil will close all the elements.
func (s *parentStack) trim(parents []string) error {
split := 0
for ; split < len(parents) && split < len(s.stack); split++ {