AttachmentAt returns the attachment at the 0-based index, or false if out of range. It re-walks the message (the caller holds the raw bytes); attachments are typically few, so a per-call walk is fine.
(raw []byte, index int)
| 53 | // range. It re-walks the message (the caller holds the raw bytes); attachments |
| 54 | // are typically few, so a per-call walk is fine. |
| 55 | func AttachmentAt(raw []byte, index int) (Attachment, bool) { |
| 56 | atts := Attachments(raw) |
| 57 | if index < 0 || index >= len(atts) { |
| 58 | return Attachment{}, false |
| 59 | } |
| 60 | return atts[index], true |
| 61 | } |
| 62 | |
| 63 | // collectAttachments appends attachment leaves found under this part to *out. |
| 64 | func collectAttachments(contentType, cte, disposition, partFilename string, body io.Reader, depth int, out *[]Attachment) { |