parseConsoleTag parses the console struct tag
(tag string)
| 390 | |
| 391 | // parseConsoleTag parses the console struct tag |
| 392 | func parseConsoleTag(tag string) consoleTag { |
| 393 | result := consoleTag{} |
| 394 | |
| 395 | if tag == "-" { |
| 396 | result.skip = true |
| 397 | return result |
| 398 | } |
| 399 | |
| 400 | parts := strings.SplitSeq(tag, ",") |
| 401 | for part := range parts { |
| 402 | part = strings.TrimSpace(part) |
| 403 | if part == "omitempty" { |
| 404 | result.omitempty = true |
| 405 | } else if after, ok := strings.CutPrefix(part, "title:"); ok { |
| 406 | result.title = after |
| 407 | } else if after, ok := strings.CutPrefix(part, "header:"); ok { |
| 408 | result.header = after |
| 409 | } else if after, ok := strings.CutPrefix(part, "format:"); ok { |
| 410 | result.format = after |
| 411 | } else if after, ok := strings.CutPrefix(part, "default:"); ok { |
| 412 | result.defaultVal = after |
| 413 | } else if after, ok := strings.CutPrefix(part, "maxlen:"); ok { |
| 414 | maxLenStr := after |
| 415 | if len, err := strconv.Atoi(maxLenStr); err == nil { |
| 416 | result.maxLen = len |
| 417 | } |
| 418 | } |
| 419 | } |
| 420 | |
| 421 | return result |
| 422 | } |
| 423 | |
| 424 | // isZeroValue checks if a reflect.Value is the zero value for its type |
| 425 | func isZeroValue(val reflect.Value) bool { |
no outgoing calls