News for hackers. Stuff that matters.
Re:Small introduction to tags in Go by toufka on Tuesday July 21, 2015 @03:33PM (#9925085)
This is the one problem.

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
Re:Small introduction to tags in Go by biggc on Tuesday July 21, 2015 @04:59PM (#9925767)
The `go vet` tool will find these issues. Not ideal, but it will catch tag strings that compile but incorrectly formatted.

http://godoc.org/golang.org/x/tools/cmd/vet

Re:Small introduction to tags in Go by AdieuToLogic on Tuesday July 21, 2015 @11:03PM (#9927516)
> 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.