Field is syntactic sugar to define an attribute that defines a tag, e.g. for protobuf. The result is the same as calling Attribute with the "rpc:tag" meta set with the value of the first argument. Field can appear wherever Attribute can. Field takes the same arguments as Attribute with the additi
(tag any, name string, args ...any)
| 191 | // Pattern("[0-9]+") |
| 192 | // }) |
| 193 | func Field(tag any, name string, args ...any) { |
| 194 | fn := func() { Meta("rpc:tag", fmt.Sprintf("%v", tag)) } |
| 195 | if len(args) > 0 { |
| 196 | if d, ok := args[len(args)-1].(func()); ok { |
| 197 | old := fn |
| 198 | fn = func() { d(); old() } |
| 199 | args = args[:len(args)-1] |
| 200 | } |
| 201 | } |
| 202 | Attribute(name, append(args, fn)...) |
| 203 | } |
| 204 | |
| 205 | // OneOf creates a union type from a name and a list of attributes. |
| 206 | // |