About how golang tmplate transmits values, the previous survey results showed that only struct can be used, but recently an open source was opened, and it was found that map [String] interface {} was used {}, think twice, so use the code for verification.
PS, ah, golang's documents are still too weak.
Package mainimport ("FMT" "html/template" "net/HTTP" "OS ") type person struct {name stringage intemails [] stringcompany stringrole string} const Templ = 'name is {{. name} company is {{. resources. company} 'func handler (w http. responsewriter, R * HTTP. request) {chxd: = person {company: "Intel", name: "chxd"} t: = template. new ("person template") T, err: = T. parse (Templ) checkerror (ERR) var TMP map [String] interf Ace {}= map [String] interface {}{ "name": "macs", "Resources": chxd} err = T. execute (W, TMP) checkerror (ERR)} func main () {HTTP. handlefunc ("/", Handler) HTTP. listenandserve (": 8888", nil)} func checkerror (ERR error) {If Err! = Nil {FMT. println ("Fatal error", Err. Error () OS. Exit (1 )}}