Re: [go-nuts] [net.mail] ReadMessage returns nil, io.EOF when email w/o body.

2023-07-18 Thread 'Jim Idle' via golang-nuts
If you are doing any serious email work, you might find that the enmime module is useful. https://github.com/jhillyerd/enmime And perhaps this: https://github.com/gatherstars-com/jwz Jim On Wed, Jul 19, 2023 at 9:07 AM Karan Gupta wrote: > That is correct. It is the same issue. > Thanks for

Re: [go-nuts] [net.mail] ReadMessage returns nil, io.EOF when email w/o body.

2023-07-18 Thread Karan Gupta
That is correct. It is the same issue. Thanks for the help. -Karan On Wed, 19 Jul, 2023, 05:15 Ian Lance Taylor, wrote: > On Tue, Jul 18, 2023 at 4:36 PM Karan Gupta > wrote: > > > > RFC 5322 (https://www.rfc-editor.org/rfc/rfc5322#section-3.5) allows > for messages without bodies. > > ` A me

Re: [go-nuts] [net.mail] ReadMessage returns nil, io.EOF when email w/o body.

2023-07-18 Thread Ian Lance Taylor
On Tue, Jul 18, 2023 at 4:36 PM Karan Gupta wrote: > > RFC 5322 (https://www.rfc-editor.org/rfc/rfc5322#section-3.5) allows for > messages without bodies. > ` A message consists of header fields, optionally followed by a message body ` > > However, the net/mail . ReadMessage returns an error when

[go-nuts] [net.mail] ReadMessage returns nil, io.EOF when email w/o body.

2023-07-18 Thread Karan Gupta
Hello Everyone RFC 5322 (https://www.rfc-editor.org/rfc/rfc5322#section-3.5) allows for messages without bodies. ` A message consists of header fields, optionally followed by a message body ` However, the net/mail . ReadMessage returns an error when an email does not contain a body. To demonst

[go-nuts] Re: testing whether two maps are the same object

2023-07-18 Thread Jochen Voss
Thanks Jason, I get your point about DeepEqual now :) On Tuesday, 18 July 2023 at 16:52:51 UTC+1 Jason Phillips wrote: > Also note: reflect.DeepEqual doesn't *just* compare the contents of the > map. It only compares contents if the maps aren't "the same map object". > From the documentation: >

[go-nuts] Re: testing whether two maps are the same object

2023-07-18 Thread Jason Phillips
Also note: reflect.DeepEqual doesn't *just* compare the contents of the map. It only compares contents if the maps aren't "the same map object". >From the documentation: > Map values are deeply equal when all of the following are true: they are both nil or both non-nil, they have the same lengt

[go-nuts] Re: testing whether two maps are the same object

2023-07-18 Thread Jason Phillips
reflect.Value.UnsafePointer() is probably not safer than using unsafe directly, assuming you're using unsafe in a way that doesn't break the rules. Reflect is doing effectively the same unsafe.Pointer conversion under the hood [1]. It's certainly easier on the eyes, in my opinion, though. [1]

[go-nuts] Re: testing whether two maps are the same object

2023-07-18 Thread Stephen Illingworth
I like that. I think it's is quite a smart way of doing it, I don't think you need to check both maps when choosing a key. Once you've found a candidate key in one map, you can test the other map and if it *does* exist then the two maps aren't equal. You've then saved the insertion and deletio

Re: [go-nuts] testing whether two maps are the same object

2023-07-18 Thread Jochen Voss
Dear Jason, Thanks for the idea of using reflect. Do you know whether `reflect.ValueOf(a).UnsafePointer()` is somehow "safer" than `*(*uintptr)(unsafe.Pointer(&a))`? reflect.DeepEqual will not work, since it just compares contents of the maps: https://go.dev/play/p/tE_qZI2cKEd All the best,

Re: [go-nuts] testing whether two maps are the same object

2023-07-18 Thread Jason Phillips
You can also use the reflect package rather than (directly) reaching for unsafe. The reflect.DeepEqual function does something along the lines of: https://go.dev/play/p/IVt0Z-mxugh On Tuesday, July 18, 2023 at 10:45:18 AM UTC-4 Jan Mercl wrote: > On Tue, Jul 18, 2023 at 4:35 PM Jochen Voss wro

Re: [go-nuts] testing whether two maps are the same object

2023-07-18 Thread Jan Mercl
On Tue, Jul 18, 2023 at 4:35 PM Jochen Voss wrote: > Is there a better way? I have never been here and please don't do this: https://go.dev/play/p/x4QYJubXMnQ -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and s

[go-nuts] testing whether two maps are the same object

2023-07-18 Thread Jochen Voss
Dear all, To implement the "eq" operator in a simple PostScript interpreter, I need to determine whether two maps are the same object. This can be done by adding a new element to one map, and checking whether the new entry also appears in the second map, but as you can imagine, the resulting c

Re: [go-nuts] map type conversion

2023-07-18 Thread 'Jakob Borg' via golang-nuts
On 17 Jul 2023, at 14:50, Leonard Mittmann wrote: Yes, but my thought was that it might be possible to do an unsafe conversion as the underlying types are the same. I just have no idea how. https://go.dev/play/p/ViLnLvInv-1 The unsafe conversion appears to work, but it’s unsafe and not obvious