Spent a whole day trying to figure out why only the first tag in the struct was 'active':
Name string `xml:"name", db:"name"` //<--- XML works, DB doesn't
Name string `db:"name", xml:"name"` //<--- DB works, XML doesn't
The answer was, going from memory, I added a comma (,) between the tags. Should have been:
Name string `xml:"name" db:"name"`
Stupid simple mistake, but really hard to track down. There was no compiler error, the second tag failed silently, and the first tag worked, so it was really hard to find the bad code.
That along with my favorite: quote-wars. Many-a-time did I forget the quotes on the tag itself only to have it fail (without warning again...):
Name string `xml:name db:"name"` //<--- DB works, XML doesn't
> Stupid simple mistake, but really hard to track down. There was no compiler error, the second tag failed silently, and the first tag worked, so it was really hard to find the bad code.
IMHO, this is why encoding meta-information into strings fail in every incarnation I've experienced. For a retro example, we need look no further than the various data base libraries which place the SQL in strings.
Bad things happen when the compiler is crippled by "tunneling" statements through strings.
A better solution would have been a proper annotation system that is part of the spec.