添加错误返回
不知道英文区的人能否看懂Cnglish。。。
Showing
1 changed file
with
4 additions
and
2 deletions
| ... | @@ -158,7 +158,8 @@ func (e *Email) Bytes() ([]byte, error) { | ... | @@ -158,7 +158,8 @@ 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 | if len(args) < 1 || len(args) > 2 { | 161 | if len(args) < 1 && len(args) > 2 { |
| 162 | err = errors.New("Must specify a file name and number of parameters can not exceed at least two") | ||
| 162 | return | 163 | return |
| 163 | } | 164 | } |
| 164 | filename := args[0] | 165 | filename := args[0] |
| ... | @@ -178,7 +179,8 @@ func (e *Email) AttachFile(args ...string) (a *Attachment, err error) { | ... | @@ -178,7 +179,8 @@ func (e *Email) AttachFile(args ...string) (a *Attachment, err error) { |
| 178 | // Attach is used to attach content from an io.Reader to the email. | 179 | // Attach is used to attach content from an io.Reader to the email. |
| 179 | // Parameters include an io.Reader, the desired filename for the attachment, and the Content-Type. | 180 | // Parameters include an io.Reader, the desired filename for the attachment, and the Content-Type. |
| 180 | func (e *Email) Attach(r io.Reader, filename string, args ...string) (a *Attachment, err error) { | 181 | func (e *Email) Attach(r io.Reader, filename string, args ...string) (a *Attachment, err error) { |
| 181 | if len(args) < 1 || len(args) > 2 { | 182 | if len(args) < 1 && len(args) > 2 { |
| 183 | err = errors.New("Must specify a file type and number of parameters can not exceed at least two") | ||
| 182 | return | 184 | return |
| 183 | } | 185 | } |
| 184 | c := args[0] //Content-Type | 186 | c := args[0] //Content-Type | ... | ... |
-
Please register or sign in to post a comment