mnako / letters

Letters, or how to parse emails in Go
MIT License
46 stars 9 forks source link

optionally only parse email headers #72

Open rorycl opened 7 months ago

rorycl commented 7 months ago

Hi @mnako

Based on a need to parse the headers of a lot of emails, I've suggested a small patch to optionally do this following the suggestion in Discussions here.

A couple of points.

  1. I thought the simplest way of making this change was to send an optional string to ParseEmail; eg: email, err := letters.ParseEmail(r, "HeadersOnly").

  2. The email struct is reinitialised in ParseEmail to set the Headers -- see deleted line 26. I've changed that.

  3. Partly because of 2. above I had an error in the test I copied and couldn't easily see what the error was. I used Google's go-cmp module which makes it easy to diff test errors.

This is my first github pull request. Please feel free to criticise it in any way.

Cheers! Rory