How does Go get the HTML content after template rendering?

just get the rendered post-HTML content, save it to a string variable, and do not output

Jan.14,2022

look at the function signatures of template rendering: Execute (wr io.Writer, data interface {}) error
obviously the rendered content can be output to anywhere that implements the io.Writer interface, such as os.Stdout , files, buffer, etc.

type User struct {
    Name string
}

func main() {
    tpl := template.New("example")
    tpl, _ = tpl.Parse("

hello {{.Name}}

") data := User{Name: "Tom"} var buf bytes.Buffer if err := tpl.Execute(&buf, data); err != nil { log.Fatal(err) } fmt.Println(buf.String()) // //

hello Tom

}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e49b16-27291.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e49b16-27291.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?