MCPcopy Create free account
hub / github.com/github/gh-aw / parseConsoleTag

Function parseConsoleTag

pkg/console/render.go:392–422  ·  view source on GitHub ↗

parseConsoleTag parses the console struct tag

(tag string)

Source from the content-addressed store, hash-verified

390
391// parseConsoleTag parses the console struct tag
392func 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
425func isZeroValue(val reflect.Value) bool {

Callers 4

TestParseConsoleTagFunction · 0.85
computeMaxFieldLenFunction · 0.85
collectTableFieldsFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestParseConsoleTagFunction · 0.68