type User struct {
Id int `orm:"auto"`
Name string `orm:"size(100)"`
}
what the purpose of 'orm:"auto"' and 'orm:"size(100)"'.
i mean i know those field corresponds to the limits that i have set in my database, but why they are here in the code ? why there is not a structure like this ?
type User struct {
Id int
Name string
}
does it changes something ? i dont understand. thanks for reading and helping me.
First of all, it appears that you are not using GORM but something else. I will assume that herein.
does it changes something ?
Yes. These are tags that add extra attributes to the field in question.
For example, "auto"
makes the field auto-increment, and "size(100)"
… well, I think you can probably guess if you apply a little brainpower!
why there is not a structure like this ?
There is!
The following alternative structure is perfectly valid, just not what the author of your code intended:
type Result struct {
Name string
Age int
}
Consult the documentation to discover what tags you can use. You'll have to read more than just the first few paragraphs of the package description to find out how the technology works!
Disclaimer: Never used Go or this library in my life. The above comes from a quick Google and glance at the manual.