Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "html/template"
- "net/http"
- )
- var tpl *template.Template
- func init() {
- tpl = template.Must(template.ParseGlob("templates/*.gohtml"))
- }
- func main() {
- http.HandleFunc("/", index)
- http.ListenAndServe(":8080", nil)
- }
- func index(res http.ResponseWriter, req *http.Request) {
- mappy := map[int]string{
- 1: "viens",
- 2: "divi",
- 3: "tris",
- 4: "cetri",
- }
- tpl.ExecuteTemplate(res, "two.gohtml", mappy)
- }
- <body>
- Home of two.gohtml<br />
- {{range $cipars,$vards := .}}
- <li>{{$cipars}} ir "{{$vards}}"</li>
- {{end}}
- </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement