Re: [go-nuts] buffer.WriteString Error case

2018-08-07 Thread Sam Whited
On Tue, Aug 7, 2018, at 19:43, Ian Lance Taylor wrote:
> So that it implements the (unexported) interface io.stringWriter.

I've wondered about this for a while; I find myself creating a StringWriter 
interface frequently in various projects. With all the other great standard 
interfaces in the io package, I wonder why this one wasn't exported?

—Sam

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] buffer.WriteString Error case

2018-08-07 Thread Dave Cheney
So that it can be used interchangeably with *bufio.Writer. 

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] buffer.WriteString Error case

2018-08-07 Thread Ian Lance Taylor
On Tue, Aug 7, 2018 at 10:17 AM, Rohit Jain  wrote:
>
> I Just happened to look at below comment on *WriteString*
>
> ```// WriteString appends the contents of s to the buffer, growing the buffer 
> as
> // needed. The return value n is the length of s; err is always nil. If the
> // buffer becomes too large, WriteString will panic with ErrTooLarge.```
>
> >`err is always nil` and it panics if the buffer is very large
>
> Can someone explain to me why do this method returns an error then?

So that it implements the (unexported) interface io.stringWriter.

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] buffer.WriteString Error case

2018-08-07 Thread Rohit Jain
I Just happened to look at below comment on *WriteString*

```// WriteString appends the contents of s to the buffer, growing the
buffer as
// needed. The return value n is the length of s; err is always nil. If the
// buffer becomes too large, WriteString will panic with ErrTooLarge.```

>`err is always nil` and it panics if the buffer is very large

Can someone explain to me why do this method returns an error then?


Thanks
-- 
Rohit Jain

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.