I am getting this error:
template: header.gohtml:6:13: executing “header” at <.title>: title is an unexported field of struct type main.pageData
main.go
type pageData struct {
title string
firstname string
}
func apply(w http.ResponseWriter, r *http.Request) {
pd := pageData{title: "Apply"}
var firstname string
if r.Method == http.MethodPost {
firstname = r.FormValue("firstname")
pd.firstname = firstname
}
}
templates/apply.gohtml
{{template "header" .}}
<h1>APPLY</h1>
{{if .title}}
Your name is {{.title}}
{{end}}
{{template "nav-main"}}
{{template "footer"}}
templates/includes/header.gohtml
{{ define "header"}}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{{.title}}</title>
<link rel="stylesheet" href="/public">
</head>
<body>
{{end}}
What is wrong with my code?