Reputation: 692
I have model like:
type Service struct {
Id uint64
Name string
Secret string
Disabled bool
}
And want to use annotations like form
, valid
and orm
. And I can't find how I should declare these annotations. Should it be one or many? If many, what separator should I use?
Upvotes: 2
Views: 475
Reputation: 417462
Quoting from reflect.StructTag
:
By convention, tag strings are a concatenation of optionally space-separated key:"value" pairs.
So you may specify multiple key-value pairs separated by space, like:
type Service struct {
Id uint64 `form:"id" valid:"Range(1, 999)" orm:"auto"`
}
See more about tags in this answer: What are the use(s) for tags in Go?
Upvotes: 2