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

Function ParseVersionValue

pkg/stringutil/stringutil.go:54–66  ·  view source on GitHub ↗

ParseVersionValue converts version values of various types to strings. Supports string, int, int64, uint64, and float64 types. Returns empty string for unsupported types.

(version any)

Source from the content-addressed store, hash-verified

52// Supports string, int, int64, uint64, and float64 types.
53// Returns empty string for unsupported types.
54func ParseVersionValue(version any) string {
55 switch v := version.(type) {
56 case string:
57 return v
58 case int, int64, uint64:
59 return fmt.Sprintf("%d", v)
60 case float64:
61 return fmt.Sprintf("%g", v)
62 default:
63 stringutilLog.Printf("ParseVersionValue: unsupported type %T, returning empty string", version)
64 return ""
65 }
66}
67
68// FormatList formats a slice of strings as a natural-language comma-separated list
69// with an Oxford comma and "and" before the final item.

Calls 1

PrintfMethod · 0.45

Tested by 2

TestParseVersionValueFunction · 0.68