fix
修改一个错误。 看到text/template包的写法,和你的想法是一致的。
Showing
1 changed file
with
7 additions
and
12 deletions
| ... | @@ -158,16 +158,14 @@ func (e *Email) Bytes() ([]byte, error) { | ... | @@ -158,16 +158,14 @@ func (e *Email) Bytes() ([]byte, error) { |
| 158 | 158 | ||
| 159 | // Add attach file to the send mail | 159 | // Add attach file to the send mail |
| 160 | func (e *Email) AttachFile(args ...string) (a *Attachment, err error) { | 160 | func (e *Email) AttachFile(args ...string) (a *Attachment, err error) { |
| 161 | argsLength := len(args) | 161 | if len(args) < 1 || len(args) > 2 { |
| 162 | if argsLength < 1 || argsLength > 2 { | ||
| 163 | return | 162 | return |
| 164 | } | 163 | } |
| 165 | filename := args[0] | 164 | filename := args[0] |
| 166 | id := "" | 165 | id := "" |
| 167 | if argsLength > 1 { | 166 | if len(args) > 1 { |
| 168 | id = args[1] | 167 | id = args[1] |
| 169 | } | 168 | } |
| 170 | id = args[1] | ||
| 171 | f, err := os.Open(filename) | 169 | f, err := os.Open(filename) |
| 172 | if err != nil { | 170 | if err != nil { |
| 173 | return | 171 | return |
| ... | @@ -179,18 +177,15 @@ func (e *Email) AttachFile(args ...string) (a *Attachment, err error) { | ... | @@ -179,18 +177,15 @@ func (e *Email) AttachFile(args ...string) (a *Attachment, err error) { |
| 179 | 177 | ||
| 180 | // Attach is used to attach content from an io.Reader to the email. | 178 | // Attach is used to attach content from an io.Reader to the email. |
| 181 | // Parameters include an io.Reader, the desired filename for the attachment, and the Content-Type. | 179 | // Parameters include an io.Reader, the desired filename for the attachment, and the Content-Type. |
| 182 | func (e *Email) Attach(r io.Reader, filename string, ci ...string) (a *Attachment, err error) { | 180 | func (e *Email) Attach(r io.Reader, filename string, args ...string) (a *Attachment, err error) { |
| 183 | args := ci | 181 | if len(args) < 1 || len(args) > 2 { |
| 184 | argsLength := len(args) | ||
| 185 | if argsLength < 1 || argsLength > 2 { | ||
| 186 | return | 182 | return |
| 187 | } | 183 | } |
| 188 | c := args[0] | 184 | c := args[0] //Content-Type |
| 189 | id := "" | 185 | id := "" |
| 190 | if argsLength > 1 { | 186 | if len(args) > 1 { |
| 191 | id = args[1] | 187 | id = args[1] //Content-ID |
| 192 | } | 188 | } |
| 193 | id = args[1] | ||
| 194 | var buffer bytes.Buffer | 189 | var buffer bytes.Buffer |
| 195 | if _, err = io.Copy(&buffer, r); err != nil { | 190 | if _, err = io.Copy(&buffer, r); err != nil { |
| 196 | return | 191 | return | ... | ... |
-
Please register or sign in to post a comment