Шаблон Голанга, если
func main() {
router := http.ServeMux{}
router.HandleFunc("/", (func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html")
html := `
<!DOCTYPE html>
<html>
<head>
<title>Golang Template</title>
</head>
<body>
<h1>
{{ if eq "samsul" .Message }} {{ .Message }}
{{ else }} {{ else }} {{ "Hello Wordl" }}
{{ end }}
</h1>
</body>
</html>
`
temp := template.Must(template.New("index").Parse(html))
temp.ExecuteTemplate(w, "index", &ApiResponse{Code: http.StatusOK, Message: "icha"})
}))
err := http.ListenAndServe(":3000", &router)
if err != nil {
log.Fatal(err)
}
}
Restu Wahyu Saputra