wrong numbering with already numbered fields
bambam translates this struct…:
type Member struct {
id int64
Username string `capid:"0"`
UpdatedAt time.Time `capid:"3" json:"LastUpdated"`
Name *string `capid:"1" json:"DisplayName,omitempty"`
IsAdmin bool `capid:"2"`
PasswordHash *string `capid:"4" json:",omitempty"`
PasswordSalt *string `capid:"5" json:",omitempty"`
PrimaryGroupId *int `capid:"6" json:",omitempty"`
UrlToAvatar *string `json:",omitempty"`
}
To the following, assigning capid=3 twice:
type Member struct {
id int64
Username string `capid:"0"`
UpdatedAt time.Time `capid:"3" json:"LastUpdated"`
Name *string `capid:"1" json:"DisplayName,omitempty"`
IsAdmin bool `capid:"2"`
PasswordHash *string `capid:"4" json:",omitempty"`
PasswordSalt *string `capid:"5" json:",omitempty"`
PrimaryGroupId *int `capid:"6" json:",omitempty"`
UrlToAvatar *string `json:",omitempty" capid:"3"`
}
I have expected that it continued numbering, and assigned capid=7 to the last field.
Annotating the field with capid=7 will result in this error and no usable file output:
$ bambam -o capn.model -p model member.go
panic: problem in capid tag '' on field 'UrlToAvatar' in struct 'Member': number '7' is beyond the count of fields we have, largest available is 6
# …
UrlToAvatar *string `capid:"7" json:",omitempty"`
}
Although not required in this example, the order of fields in a struct is important: If every member of a struct is comparable, then the struct becomes comparable. In that case you don't want to reorder fields to suit bambam.
@wmark Thanks for reporting this. It is clearly a bug. I won't have time to take a look at this until the weekend. I'd be happy to review a fix if you'd like to prepare one.
@wmark: sadly, I won't have time any time soon to get to this...
Anyway, thanks for having looked into this. Perhaps someone else finds this and wants to pick it up.
Oh. This is due to the lack of time.Time type support. That is, bambam doesn't claim to have time.Time support currently.