Google Groups

Re: [go-nuts] Re: django.forms-style value cleaning, validation and error collecting

Kyle Lemons May 17, 2011 5:34 PM
Posted in group: golang-nuts
> As Kyle mentioned, customization of the form and making it play nicely
> with template package would be ideal. Since I am not a power user, I
> am not in a position to suggest anything about it.
> thanks,
> Babu.

My brain has been thinking about this quite a bit, and I may take a
stab at it too at some point.  One interesting, possibly useful, thing
to do would be to use reflection in the formatter of a template
argument to automatically create form elements.  For example:

<form ...>

It looks pretty ugly; better names could probably be chosen.  These
can (would? should?) complement a mechanism for reading form data from
the request into the structure.  This sort of mechanism could help
close the gap between writing forms and writing the code that
processes them; it would make it trivial to validate form data on the
Go side and just redisplay the form if it's wrong, because the data
and its representation are coupled.

Just some musings.  I don't know if I have yet stumbled on the "right"
way to do this, but I think it is a worthwhile conversation to have,
so that maybe a "canonical" way, or a "go-like" way of doing it can
emerge and maybe be integrated into GAE.
"Everyone knows that debugging is twice as hard as writing a program
in the first place. So if you're as clever as you can be when you
write it, how will you ever debug it?"
— Brian Kernighan