ParseStandardTag extracts the sub-tag named by key, then parses it using the de facto standard format introduced in encoding/json: "-" means "ignore this tag", unless it has options (that is, is followed by a comma), in which case it is treated a name. " " provides an alternative name f
(key string, t reflect.StructTag)
| 482 | // |
| 483 | // The options are returned as a []string. |
| 484 | func ParseStandardTag(key string, t reflect.StructTag) (name string, keep bool, options []string) { |
| 485 | s := t.Get(key) |
| 486 | parts := strings.Split(s, ",") |
| 487 | if parts[0] == "-" && len(parts) == 1 { |
| 488 | return "", false, nil |
| 489 | } |
| 490 | if len(parts) > 1 { |
| 491 | options = parts[1:] |
| 492 | } |
| 493 | return parts[0], true, options |
| 494 | } |