Update index.md (#18912)

Updated Page struct and Name attribute in the Struct to follow best practices for Naming structs from [here](https://golang.org/doc/effective_go.html)
This commit is contained in:
Harsha Gudladona
2018-10-15 17:39:46 -04:00
committed by Quincy Larson
parent dc442f82b4
commit 9792d0976a

View File

@ -10,11 +10,11 @@ import (
"html/template"
)
type PAGE struct {
NAME string
type Page struct {
Name string
}
var page PAGE
var page Page
func main() {
http.HandleFunc("/", servePage)
@ -22,9 +22,9 @@ func main() {
}
func servePage(writer http.ResponseWriter, reqest *http.Request) {
page.NAME = request.FormValue("name")
page.Name = request.FormValue("name")
template := template.New("sayHello")
template, _ = template.Parse("Hello {{.NAME}}!")
template, _ = template.Parse("Hello {{.Name}}!")
template.Execute(writer, page)
}
```