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)
| 52 | // Supports string, int, int64, uint64, and float64 types. |
| 53 | // Returns empty string for unsupported types. |
| 54 | func 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. |