package utils import ( "strings" "text/template" ) func TextTemplateMatch(obj any, textTemplate string) (string, error) { // 定义模板字符串 tmpl, err := template.New("template").Parse(textTemplate) if err != nil { panic(err) } sb := strings.Builder{} err = tmpl.Execute(&sb, obj) if err != nil { return "", err } sbs := sb.String() return sbs, err }