diff --git a/index.html b/index.html index 522de3a..9451cbf 100644 --- a/index.html +++ b/index.html @@ -10,6 +10,12 @@ Document -

Hello-Bootstrap

+

Hello-Bootstrap

+ + {{ range .Films }} + +

{{ .Title }} - {{ .Director }}

+ + {{ end }} \ No newline at end of file diff --git a/main.go b/main.go index f680b54..a0a5fb4 100644 --- a/main.go +++ b/main.go @@ -7,12 +7,24 @@ import ( "text/template" ) +type Film struct { + Title string + Director string +} + func main() { fmt.Println("hello world") h1 := func(w http.ResponseWriter, r *http.Request) { tmpl := template.Must(template.ParseFiles("index.html")) - tmpl.Execute(w, nil) + films := map[string][]Film{ + "Films": { + {Title: "The Goodfather", Director: "Francis Ford Coppola"}, + {Title: "Blade Runner", Director: "Ridley Scott"}, + {Title: "The Thing", Director: "John Carpenter"}, + }, + } + tmpl.Execute(w, films) } http.HandleFunc("/", h1)