main.go 463 B

123456789101112131415161718192021222324252627
  1. package main
  2. import (
  3. "html/template"
  4. "log"
  5. "net/http"
  6. )
  7. var templates *template.Template
  8. type usuario struct {
  9. Nome string
  10. Email string
  11. }
  12. func main() {
  13. u := usuario{"Fernando Paschoeto", "fernandopaschoeto@gmail.com"}
  14. templates = template.Must(template.ParseGlob("*.html"))
  15. http.HandleFunc("/home", func(w http.ResponseWriter, r *http.Request) {
  16. templates.ExecuteTemplate(w, "index.html", u)
  17. })
  18. log.Fatal(http.ListenAndServe(":5000", nil))
  19. }