diff --git a/src/pkg/encoding/xml/marshal.go b/src/pkg/encoding/xml/marshal.go index 06bdec4f73..a6ee5d5128 100644 --- a/src/pkg/encoding/xml/marshal.go +++ b/src/pkg/encoding/xml/marshal.go @@ -196,6 +196,7 @@ func (enc *Encoder) EncodeToken(t Token) error { p.WriteString("") + return p.cachedWriteError() case ProcInst: if t.Target == "xml" || !isNameString(t.Target) { return fmt.Errorf("xml: EncodeToken of ProcInst with invalid Target") @@ -218,7 +219,7 @@ func (enc *Encoder) EncodeToken(t Token) error { p.Write(t) p.WriteString(">") } - return p.Flush() + return p.cachedWriteError() } type printer struct { diff --git a/src/pkg/encoding/xml/marshal_test.go b/src/pkg/encoding/xml/marshal_test.go index 31d4d4d853..8d9239eb4a 100644 --- a/src/pkg/encoding/xml/marshal_test.go +++ b/src/pkg/encoding/xml/marshal_test.go @@ -1076,15 +1076,6 @@ func TestMarshalWriteIOErrors(t *testing.T) { } } -func TestEncodeTokenFlush(t *testing.T) { - var buf bytes.Buffer - enc := NewEncoder(&buf) - enc.EncodeToken(StartElement{Name: Name{Local: "some-tag"}}) - if g, w := buf.String(), ""; g != w { - t.Errorf("Encoder wrote %q, want %q", g, w) - } -} - func BenchmarkMarshal(b *testing.B) { for i := 0; i < b.N; i++ { Marshal(atomValue)