在这段代码中,我想在HTML文件中使用并给出一个特定的细节,比如标题或价格。
{{.Heading}}
package main
import "net/http"
type Details struct {
Heading string
Price string
}
var Detail = []Details{
{
Heading: "First Cloth",
Price: "$59",
},
{
Heading: "Second Cloth",
Price: "$49",
},
}
func Main(w http.ResponseWriter, r *http.Request) {
HomeTmpl.Execute(w, Detail)
// fmt.Println(Detail[1].Heading) // For specific data
}