Challenge for November, 2016
Use struct tags to build a form dynamically. Use Go templates to display the form.
type UserData struct {
FullName string `name:"fullname" desc:"Full name"`
Email string `name:"email" desc:"Email address"`
Phone string `name:"phone" desc:"Phone number"`
}
Build the form. Suggested steps:
- Read the struct tags using the
reflect
package - Use the struct tag data to build a form of user data
- Add more user data fields and/or tags that affect behavior (ex: field is required)
Resources:
Validate the form data using struct tags.
Suggested steps:
- Add
valid
struct tag to theUserData
struct - Handle form POST of user data
- Validate submitted data and display result
Resources:
Maintain list of users submitted and provide a way to display user data.