1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-26 05:11:31 +00:00
修改一个错误。
看到text/template包的写法,和你的想法是一致的。
This commit is contained in:
TossPig 2014-10-11 00:02:36 +08:00
parent 6a33647f30
commit 41de7c7db6

View File

@ -158,16 +158,14 @@ func (e *Email) Bytes() ([]byte, error) {
// Add attach file to the send mail // Add attach file to the send mail
func (e *Email) AttachFile(args ...string) (a *Attachment, err error) { func (e *Email) AttachFile(args ...string) (a *Attachment, err error) {
argsLength := len(args) if len(args) < 1 || len(args) > 2 {
if argsLength < 1 || argsLength > 2 {
return return
} }
filename := args[0] filename := args[0]
id := "" id := ""
if argsLength > 1 { if len(args) > 1 {
id = args[1] id = args[1]
} }
id = args[1]
f, err := os.Open(filename) f, err := os.Open(filename)
if err != nil { if err != nil {
return return
@ -179,18 +177,15 @@ func (e *Email) AttachFile(args ...string) (a *Attachment, err error) {
// Attach is used to attach content from an io.Reader to the email. // Attach is used to attach content from an io.Reader to the email.
// Parameters include an io.Reader, the desired filename for the attachment, and the Content-Type. // Parameters include an io.Reader, the desired filename for the attachment, and the Content-Type.
func (e *Email) Attach(r io.Reader, filename string, ci ...string) (a *Attachment, err error) { func (e *Email) Attach(r io.Reader, filename string, args ...string) (a *Attachment, err error) {
args := ci if len(args) < 1 || len(args) > 2 {
argsLength := len(args)
if argsLength < 1 || argsLength > 2 {
return return
} }
c := args[0] c := args[0] //Content-Type
id := "" id := ""
if argsLength > 1 { if len(args) > 1 {
id = args[1] id = args[1] //Content-ID
} }
id = args[1]
var buffer bytes.Buffer var buffer bytes.Buffer
if _, err = io.Copy(&buffer, r); err != nil { if _, err = io.Copy(&buffer, r); err != nil {
return return