Created
December 27, 2014 17:55
-
-
Save mmirolim/ee4130b75b1557c91c78 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "html/template" | |
| "log" | |
| "net/http" | |
| "time" | |
| ) | |
| func main() { | |
| http.HandleFunc("/show", Show) | |
| log.Fatal(http.ListenAndServe(":3000", nil)) | |
| } | |
| func Show(w http.ResponseWriter, r *http.Request) { | |
| now := time.Now() | |
| t, err := template.New("foo").Parse(`{{define "T"}}Time, {{.}}!{{end}}`) | |
| err = t.ExecuteTemplate(w, "T", now) | |
| if err != nil { | |
| log.Fatalln(err) | |
| } | |
| } | |
| // outputs -> Time, 2014-12-27 22:53:17.638884509 +0500 UZT! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment