test.html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Go Web</title>
</head>
<body>
<ul>
{{ range . }}
<li>{{ . }}</li>
{{ else }}
<li> Nothing to show </li>
{{ end}}
</ul>
</body>
</html>
main.go
package main
import (
"html/template"
"net/http"
)
func main() {
server := http.Server{
Addr: "127.0.0.1:8080",
}
http.HandleFunc("/process", process)
server.ListenAndServe()
}
func process(w http.ResponseWriter, r *http.Request) {
t1 := template.Must(template.ParseFiles("test.html"))
s := []string{
"星期一",
"星期二",
"星期三",
"星期四",
"星期五",
"星期六",
"星期日",}
t1.Execute(w, s)
}

