Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
43a39bfd
Commit
43a39bfd
authored
Aug 19, 2013
by
Dominik Honnef
Committed by
Andrew Gerrand
Aug 19, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
encoding/xml: flush buffer after encoding token
R=rsc, bradfitz, adg CC=golang-dev
https://golang.org/cl/13004046
parent
7fb121aa
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
2 deletions
+10
-2
marshal.go
src/pkg/encoding/xml/marshal.go
+1
-2
marshal_test.go
src/pkg/encoding/xml/marshal_test.go
+9
-0
No files found.
src/pkg/encoding/xml/marshal.go
View file @
43a39bfd
...
...
@@ -196,7 +196,6 @@ func (enc *Encoder) EncodeToken(t Token) error {
p
.
WriteString
(
"<!--"
)
p
.
Write
(
t
)
p
.
WriteString
(
"-->"
)
return
p
.
cachedWriteError
()
case
ProcInst
:
if
t
.
Target
==
"xml"
||
!
isNameString
(
t
.
Target
)
{
return
fmt
.
Errorf
(
"xml: EncodeToken of ProcInst with invalid Target"
)
...
...
@@ -219,7 +218,7 @@ func (enc *Encoder) EncodeToken(t Token) error {
p
.
Write
(
t
)
p
.
WriteString
(
">"
)
}
return
p
.
cachedWriteError
()
return
p
.
Flush
()
}
type
printer
struct
{
...
...
src/pkg/encoding/xml/marshal_test.go
View file @
43a39bfd
...
...
@@ -1076,6 +1076,15 @@ 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
(),
"<some-tag>"
;
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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment