【发布时间】:2016-09-04 15:06:21
【问题描述】:
在“go”到 os.Stdout 中执行模板(在我的情况下为“tmplhtml”)很容易,但是如何将其写入字符串“输出”以便我以后可以发送 html使用"gopkg.in/gomail.v2" 发送邮件?
var output string
t := template.Must(template.New("html table").Parse(tmplhtml))
err = t.Execute(output, Files)
m.SetBody("text/html", output) //"gopkg.in/gomail.v2"
构建错误读取 'cannot use output (type string) as type io.Writer in argument to t.Execute: string does not implement io.Writer (missing Write method)' 我可以实现 Writer方法,但它应该返回整数 Write(p []byte) (n int, err error)
【问题讨论】:
标签: go