Re: [go-nuts] What happened to sep in errorrs.join

2024-07-03 Thread Marian Ciobanu
Unless I'm missing something, these are equivalent:
errors.Join(err1, err2)
fmt.Errorf("%w\n%w", err1, err2)

So you can use the second form to achieve something similar to whatever 
separator you want to use.
On Thursday, August 10, 2023 at 4:35:16 AM UTC+3 jal...@gmail.com wrote:

> this works fine for my purposes
>
> https://go.dev/play/p/YSoeYS09v4O
>
> Thanks,
> Joe
>
> On Wednesday, August 9, 2023 at 2:34:08 AM UTC-5 Tamás Gulácsi wrote:
>
>> Strange. AFAIK the JSON handler escapes the \n in strings.
>>
>> Joseph Lorenzini a következőt írta (2023. augusztus 8., kedd, 13:24:56 
>> UTC+2):
>>
>>> Thanks that was very helpful. As for your point about slog, yes a custom 
>>> handler could but I am using the library json handler.
>>>
>>> I suppose the proper way to frame my problem is that I am using the slog 
>>> library handler and I do not want new lines in the message or keys. 
>>>
>>> Would the go team would be open to providing knobs to control how the 
>>> handler does formatting? I assumed if I tried opening a proposal like that 
>>> I’d be told to write a custom handler. :) 
>>>
>>> On Mon, Aug 7, 2023 at 3:56 PM Ian Lance Taylor  
>>> wrote:
>>>
 On Mon, Aug 7, 2023 at 4:32 AM jal...@gmail.com  
 wrote:
 >
 > In the errors.join proposal, the proposed api had the user specify 
 how they wanted the errors to be formatted together. But the actual 
 implementation omitted and only used new line.
 >
 > This is quite unfortunate if you are using slog and want to log that 
 error and very much need a log statement to not span multiple lines. It 
 also makes it much harder to read.
 >
 > Does anyone recall why sep was dropped?

 See the discussion at https://go.dev/issue/53435, especially
 https://github.com/golang/go/issues/53435#issuecomment-1190654775 and
 https://github.com/golang/go/issues/53435#issuecomment-1190845424.

 As far as the slog package it seems to me that a handler can enforce
 that individual messages are on a single line.  There may be a better
 way to address that problem, but I don't think that errors.Join is the
 right place for a fix.  Any random package can generate multiline
 error messages with errors.New("a\nb"), and I've seen plenty that do.
 So enforcing single-line messages on errors.Join won't fix the problem
 in general.

 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/d975d7d3-87d0-4b5e-9a85-c2948aaa60e4n%40googlegroups.com.


Re: [go-nuts] What happened to sep in errorrs.join

2023-08-09 Thread jal...@gmail.com
this works fine for my purposes

https://go.dev/play/p/YSoeYS09v4O

Thanks,
Joe

On Wednesday, August 9, 2023 at 2:34:08 AM UTC-5 Tamás Gulácsi wrote:

> Strange. AFAIK the JSON handler escapes the \n in strings.
>
> Joseph Lorenzini a következőt írta (2023. augusztus 8., kedd, 13:24:56 
> UTC+2):
>
>> Thanks that was very helpful. As for your point about slog, yes a custom 
>> handler could but I am using the library json handler.
>>
>> I suppose the proper way to frame my problem is that I am using the slog 
>> library handler and I do not want new lines in the message or keys. 
>>
>> Would the go team would be open to providing knobs to control how the 
>> handler does formatting? I assumed if I tried opening a proposal like that 
>> I’d be told to write a custom handler. :) 
>>
>> On Mon, Aug 7, 2023 at 3:56 PM Ian Lance Taylor  wrote:
>>
>>> On Mon, Aug 7, 2023 at 4:32 AM jal...@gmail.com  
>>> wrote:
>>> >
>>> > In the errors.join proposal, the proposed api had the user specify how 
>>> they wanted the errors to be formatted together. But the actual 
>>> implementation omitted and only used new line.
>>> >
>>> > This is quite unfortunate if you are using slog and want to log that 
>>> error and very much need a log statement to not span multiple lines. It 
>>> also makes it much harder to read.
>>> >
>>> > Does anyone recall why sep was dropped?
>>>
>>> See the discussion at https://go.dev/issue/53435, especially
>>> https://github.com/golang/go/issues/53435#issuecomment-1190654775 and
>>> https://github.com/golang/go/issues/53435#issuecomment-1190845424.
>>>
>>> As far as the slog package it seems to me that a handler can enforce
>>> that individual messages are on a single line.  There may be a better
>>> way to address that problem, but I don't think that errors.Join is the
>>> right place for a fix.  Any random package can generate multiline
>>> error messages with errors.New("a\nb"), and I've seen plenty that do.
>>> So enforcing single-line messages on errors.Join won't fix the problem
>>> in general.
>>>
>>> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/5577c63b-722e-4112-bf11-c27b02ac6bd2n%40googlegroups.com.


Re: [go-nuts] What happened to sep in errorrs.join

2023-08-09 Thread Tamás Gulácsi
Strange. AFAIK the JSON handler escapes the \n in strings.

Joseph Lorenzini a következőt írta (2023. augusztus 8., kedd, 13:24:56 
UTC+2):

> Thanks that was very helpful. As for your point about slog, yes a custom 
> handler could but I am using the library json handler.
>
> I suppose the proper way to frame my problem is that I am using the slog 
> library handler and I do not want new lines in the message or keys. 
>
> Would the go team would be open to providing knobs to control how the 
> handler does formatting? I assumed if I tried opening a proposal like that 
> I’d be told to write a custom handler. :) 
>
> On Mon, Aug 7, 2023 at 3:56 PM Ian Lance Taylor  wrote:
>
>> On Mon, Aug 7, 2023 at 4:32 AM jal...@gmail.com  wrote:
>> >
>> > In the errors.join proposal, the proposed api had the user specify how 
>> they wanted the errors to be formatted together. But the actual 
>> implementation omitted and only used new line.
>> >
>> > This is quite unfortunate if you are using slog and want to log that 
>> error and very much need a log statement to not span multiple lines. It 
>> also makes it much harder to read.
>> >
>> > Does anyone recall why sep was dropped?
>>
>> See the discussion at https://go.dev/issue/53435, especially
>> https://github.com/golang/go/issues/53435#issuecomment-1190654775 and
>> https://github.com/golang/go/issues/53435#issuecomment-1190845424.
>>
>> As far as the slog package it seems to me that a handler can enforce
>> that individual messages are on a single line.  There may be a better
>> way to address that problem, but I don't think that errors.Join is the
>> right place for a fix.  Any random package can generate multiline
>> error messages with errors.New("a\nb"), and I've seen plenty that do.
>> So enforcing single-line messages on errors.Join won't fix the problem
>> in general.
>>
>> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/e49a8b4e-571a-4641-b3e9-8ef98716d03an%40googlegroups.com.


Re: [go-nuts] What happened to sep in errorrs.join

2023-08-08 Thread 'Jonathan Amsterdam' via golang-nuts
I think you can do what you want with `HandlerOptions.ReplaceAttr`. It is 
given every attribute, even the message.
It can't change the group names, though, and those can have newlines.


On Tuesday, August 8, 2023 at 5:47:38 PM UTC-4 Ian Lance Taylor wrote:

> [ + jba ]
>
> On Tue, Aug 8, 2023 at 4:24 AM Joseph Lorenzini  wrote:
> >
> > Thanks that was very helpful. As for your point about slog, yes a custom 
> handler could but I am using the library json handler.
> >
> > I suppose the proper way to frame my problem is that I am using the slog 
> library handler and I do not want new lines in the message or keys.
> >
> > Would the go team would be open to providing knobs to control how the 
> handler does formatting? I assumed if I tried opening a proposal like that 
> I’d be told to write a custom handler. :)
> >
> > On Mon, Aug 7, 2023 at 3:56 PM Ian Lance Taylor  
> wrote:
> >>
> >> On Mon, Aug 7, 2023 at 4:32 AM jal...@gmail.com  
> wrote:
> >> >
> >> > In the errors.join proposal, the proposed api had the user specify 
> how they wanted the errors to be formatted together. But the actual 
> implementation omitted and only used new line.
> >> >
> >> > This is quite unfortunate if you are using slog and want to log that 
> error and very much need a log statement to not span multiple lines. It 
> also makes it much harder to read.
> >> >
> >> > Does anyone recall why sep was dropped?
> >>
> >> See the discussion at https://go.dev/issue/53435, especially
> >> https://github.com/golang/go/issues/53435#issuecomment-1190654775 and
> >> https://github.com/golang/go/issues/53435#issuecomment-1190845424.
> >>
> >> As far as the slog package it seems to me that a handler can enforce
> >> that individual messages are on a single line. There may be a better
> >> way to address that problem, but I don't think that errors.Join is the
> >> right place for a fix. Any random package can generate multiline
> >> error messages with errors.New("a\nb"), and I've seen plenty that do.
> >> So enforcing single-line messages on errors.Join won't fix the problem
> >> in general.
> >>
> >> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/e9f2b5a1-d782-48a3-a073-00dc4087c0d9n%40googlegroups.com.


Re: [go-nuts] What happened to sep in errorrs.join

2023-08-08 Thread Ian Lance Taylor
[ + jba ]

On Tue, Aug 8, 2023 at 4:24 AM Joseph Lorenzini  wrote:
>
> Thanks that was very helpful. As for your point about slog, yes a custom 
> handler could but I am using the library json handler.
>
> I suppose the proper way to frame my problem is that I am using the slog 
> library handler and I do not want new lines in the message or keys.
>
> Would the go team would be open to providing knobs to control how the handler 
> does formatting? I assumed if I tried opening a proposal like that I’d be 
> told to write a custom handler. :)
>
> On Mon, Aug 7, 2023 at 3:56 PM Ian Lance Taylor  wrote:
>>
>> On Mon, Aug 7, 2023 at 4:32 AM jal...@gmail.com  wrote:
>> >
>> > In the errors.join proposal, the proposed api had the user specify how 
>> > they wanted the errors to be formatted together. But the actual 
>> > implementation omitted and only used new line.
>> >
>> > This is quite unfortunate if you are using slog and want to log that error 
>> > and very much need a log statement to not span multiple lines. It also 
>> > makes it much harder to read.
>> >
>> > Does anyone recall why sep was dropped?
>>
>> See the discussion at https://go.dev/issue/53435, especially
>> https://github.com/golang/go/issues/53435#issuecomment-1190654775 and
>> https://github.com/golang/go/issues/53435#issuecomment-1190845424.
>>
>> As far as the slog package it seems to me that a handler can enforce
>> that individual messages are on a single line.  There may be a better
>> way to address that problem, but I don't think that errors.Join is the
>> right place for a fix.  Any random package can generate multiline
>> error messages with errors.New("a\nb"), and I've seen plenty that do.
>> So enforcing single-line messages on errors.Join won't fix the problem
>> in general.
>>
>> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcVRUUrjkX5owdhW-Y-_yc2QsD0ajK%3D-ccMrHU3NxTLidw%40mail.gmail.com.


Re: [go-nuts] What happened to sep in errorrs.join

2023-08-08 Thread Joseph Lorenzini
Thanks that was very helpful. As for your point about slog, yes a custom
handler could but I am using the library json handler.

I suppose the proper way to frame my problem is that I am using the slog
library handler and I do not want new lines in the message or keys.

Would the go team would be open to providing knobs to control how the
handler does formatting? I assumed if I tried opening a proposal like that
I’d be told to write a custom handler. :)

On Mon, Aug 7, 2023 at 3:56 PM Ian Lance Taylor  wrote:

> On Mon, Aug 7, 2023 at 4:32 AM jal...@gmail.com  wrote:
> >
> > In the errors.join proposal, the proposed api had the user specify how
> they wanted the errors to be formatted together. But the actual
> implementation omitted and only used new line.
> >
> > This is quite unfortunate if you are using slog and want to log that
> error and very much need a log statement to not span multiple lines. It
> also makes it much harder to read.
> >
> > Does anyone recall why sep was dropped?
>
> See the discussion at https://go.dev/issue/53435, especially
> https://github.com/golang/go/issues/53435#issuecomment-1190654775 and
> https://github.com/golang/go/issues/53435#issuecomment-1190845424.
>
> As far as the slog package it seems to me that a handler can enforce
> that individual messages are on a single line.  There may be a better
> way to address that problem, but I don't think that errors.Join is the
> right place for a fix.  Any random package can generate multiline
> error messages with errors.New("a\nb"), and I've seen plenty that do.
> So enforcing single-line messages on errors.Join won't fix the problem
> in general.
>
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAMvD0VK7JkStS-wuFmkmBROh0f5WbcNuAD-sHDynS0Oq8CS%2B1Q%40mail.gmail.com.


Re: [go-nuts] What happened to sep in errorrs.join

2023-08-07 Thread Ian Lance Taylor
On Mon, Aug 7, 2023 at 4:32 AM jal...@gmail.com  wrote:
>
> In the errors.join proposal, the proposed api had the user specify how they 
> wanted the errors to be formatted together. But the actual implementation 
> omitted and only used new line.
>
> This is quite unfortunate if you are using slog and want to log that error 
> and very much need a log statement to not span multiple lines. It also makes 
> it much harder to read.
>
> Does anyone recall why sep was dropped?

See the discussion at https://go.dev/issue/53435, especially
https://github.com/golang/go/issues/53435#issuecomment-1190654775 and
https://github.com/golang/go/issues/53435#issuecomment-1190845424.

As far as the slog package it seems to me that a handler can enforce
that individual messages are on a single line.  There may be a better
way to address that problem, but I don't think that errors.Join is the
right place for a fix.  Any random package can generate multiline
error messages with errors.New("a\nb"), and I've seen plenty that do.
So enforcing single-line messages on errors.Join won't fix the problem
in general.

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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcV%3D1QeVeiJnaVZadNN8Mg2YVsb3oLeUTay%2Bm6dJ9PHhQQ%40mail.gmail.com.


[go-nuts] What happened to sep in errorrs.join

2023-08-07 Thread jal...@gmail.com
In the errors.join proposal , 
the proposed api had the user specify how they wanted the errors to be 
formatted together. But the actual implementation omitted and only used new 
line.

This is quite unfortunate if you are using slog and want to log that error 
and very much need a log statement to not span multiple lines. It also 
makes it much harder to read. 

Does anyone recall why sep was dropped?

Thanks,
Joe 


-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/a92003f1-b33d-4bce-b582-1f0edaea1660n%40googlegroups.com.