we_message.go 466 B

12345678910111213141516171819202122
  1. package third_party
  2. import (
  3. "bytes"
  4. "fmt"
  5. "text/template"
  6. "time"
  7. )
  8. func TextContentParse(content string, nickname string) string {
  9. t, _ := template.New("text").Parse(content)
  10. buf := new(bytes.Buffer)
  11. err := t.Execute(buf, map[string]interface{}{
  12. "DateTime": time.Now().Format("1月2日"),
  13. "Nickname": nickname,
  14. })
  15. if err != nil {
  16. fmt.Printf("格式转换出错了,content:%s,err:%s", content, err)
  17. return content
  18. }
  19. return string(buf.Bytes())
  20. }