我正在使用此代码:
err := smtp.SendMail(
smtpHostPort,
auth,
sender,
[]string{recipient},
[]byte(message),
)
if err != nil {
log.Printf("sendSmtp: failure: %q", strings.Split(err.Error(), "\n"))
}
然而,多行错误响应似乎被截断:
2013/02/06 11:54:41 sendSmtp: failure: ["530 5.5.1 Authentication Required. Learn more at"]
如何获得完整的多行错误响应?
答案 0 :(得分:1)
对于记录,此错误已得到修复:
答案 1 :(得分:0)
错误不是多行字符串。
package main
import (
"errors"
"log"
"strings"
)
func main() {
err := errors.New("530 5.5.1 Authentication Required. Learn more at")
log.Printf("sendSmtp: failure: %q", strings.Split(err.Error(), "\n"))
err = errors.New("530 5.5.1 Authentication Required. Learn more at\nstackoverflow.com")
log.Printf("sendSmtp: failure: %q", strings.Split(err.Error(), "\n"))
}
输出:
2013/02/06 13:30:19 sendSmtp: failure: ["530 5.5.1 Authentication Required. Learn more at"]
2013/02/06 13:30:19 sendSmtp: failure: ["530 5.5.1 Authentication Required. Learn more at" "stackoverflow.com"]