On 2013/08/17 08:32:13, bradfitz wrote: > All the tests already pass. There are no tests ...
11 years, 9 months ago
(2013-08-17 17:16:30 UTC)
#3
On 2013/08/17 08:32:13, bradfitz wrote:
> All the tests already pass.
There are no tests for this function, but I'm not the right one to write them.
To demonstrate the problem, however: http://play.golang.org/p/w0ruXyhgSV will
not produce any output.
Here's your test (not tested ;-): func TestEncodeTokenFlush(t *testing.T) { var b bytes.Buffer enc := ...
11 years, 9 months ago
(2013-08-18 22:25:01 UTC)
#4
Here's your test (not tested ;-):
func TestEncodeTokenFlush(t *testing.T) {
var b bytes.Buffer
enc := xml.NewEncoder(&b)
enc.EncodeToken(xml.StartElement{Name: xml.Name{Local: "some-tag"}})
if g, w := b.Len(), len("<some-tag>"); g != w {
t.Errorf("Encoder wrote %v bytes, want %v", g, w)
}
}
Told you I wasn't the right person ;-) https://codereview.appspot.com/13004046/diff/14002/src/pkg/encoding/xml/marshal_test.go File src/pkg/encoding/xml/marshal_test.go (right): https://codereview.appspot.com/13004046/diff/14002/src/pkg/encoding/xml/marshal_test.go#newcode1084 src/pkg/encoding/xml/marshal_test.go:1084: t.Errorf("Encoder ...
11 years, 9 months ago
(2013-08-18 23:58:48 UTC)
#9
On 2013/09/03 20:30:07, rsc wrote: > This is wrong and should be undone. > > ...
11 years, 8 months ago
(2013-09-03 20:38:38 UTC)
#14
Message was sent while issue was closed.
On 2013/09/03 20:30:07, rsc wrote:
> This is wrong and should be undone.
>
> Flushing after every token negates nearly the entire advantage of buffering
> writes in the first place.
>
> Russ
Are you opposed to adding a method to explicitly flush? My concrete problem is
that I am sending tokens down an XML stream (XMPP) and I need an
xml.StartElement to go down the wire as I send it.
On 2013/09/03 20:38:38, Dominik Honnef wrote: > On 2013/09/03 20:30:07, rsc wrote: > > This ...
11 years, 8 months ago
(2013-09-03 20:52:14 UTC)
#15
Message was sent while issue was closed.
On 2013/09/03 20:38:38, Dominik Honnef wrote:
> On 2013/09/03 20:30:07, rsc wrote:
> > This is wrong and should be undone.
> >
> > Flushing after every token negates nearly the entire advantage of buffering
> > writes in the first place.
> >
> > Russ
>
> Are you opposed to adding a method to explicitly flush? My concrete problem is
> that I am sending tokens down an XML stream (XMPP) and I need an
> xml.StartElement to go down the wire as I send it.
Actually, looking at it, how *do* you ensure that the buffer is flushed at any
given time? If all I am doing is using EncodeToken, I won't know how much of it
has reached the io.Writer of the Encoder.
On 4 September 2013 06:30, Russ Cox <rsc@golang.org> wrote: > This is wrong and should ...
11 years, 8 months ago
(2013-09-04 00:44:49 UTC)
#16
On 4 September 2013 06:30, Russ Cox <rsc@golang.org> wrote:
> This is wrong and should be undone.
>
> Flushing after every token negates nearly the entire advantage of
> buffering writes in the first place.
>
Without some change it is impossible to use EncodeToken correctly.
EncodeToken is not used by other parts of package xml. The buffering in the
encoder is obviously useful for the implementation of the Encode method,
but users of EncodeToken should perhaps be doing their own buffering anyway.
If you don't like this change, then we should add a Flush method to
Encoder, as Dominik suggests.
On Tue, Sep 3, 2013 at 8:44 PM, Andrew Gerrand <adg@golang.org> wrote: > > On ...
11 years, 8 months ago
(2013-09-05 16:03:28 UTC)
#17
On Tue, Sep 3, 2013 at 8:44 PM, Andrew Gerrand <adg@golang.org> wrote:
>
> On 4 September 2013 06:30, Russ Cox <rsc@golang.org> wrote:
>
>> This is wrong and should be undone.
>>
>> Flushing after every token negates nearly the entire advantage of
>> buffering writes in the first place.
>>
>
> Without some change it is impossible to use EncodeToken correctly.
>
That's not strictly true. If you use it during the implementation of a
custom MarshalXML method, it works correctly without the flush, because
there will be a flush when the whole XML stream is done.
EncodeToken is not used by other parts of package xml. The buffering in the
> encoder is obviously useful for the implementation of the Encode method,
> but users of EncodeToken should perhaps be doing their own buffering anyway.
>
> If you don't like this change, then we should add a Flush method to
> Encoder, as Dominik suggests.
>
I agree that there should be a Flush.
Russ
Issue 13004046: code review 13004046: encoding/xml: flush buffer after encoding token
(Closed)
Created 11 years, 9 months ago by Dominik Honnef
Modified 11 years, 8 months ago
Reviewers:
Base URL:
Comments: 6