MCPcopy Create free account
hub / github.com/gokcehan/lf / fieldToString

Function fieldToString

main.go:104–131  ·  view source on GitHub ↗

used by exportOpts below

(field reflect.Value)

Source from the content-addressed store, hash-verified

102
103// used by exportOpts below
104func fieldToString(field reflect.Value) string {
105 // prevent returning <main.borderStyle Value>
106 if field.Type() == reflect.TypeFor[borderStyle]() {
107 return borderStyle(field.Uint()).String()
108 }
109
110 var value string
111 switch field.Kind() {
112 case reflect.Int:
113 value = strconv.Itoa(int(field.Int()))
114 case reflect.Bool:
115 value = strconv.FormatBool(field.Bool())
116 case reflect.Slice:
117 for i := range field.Len() {
118 element := field.Index(i)
119
120 if i == 0 {
121 value = fieldToString(element)
122 } else {
123 value += ":" + fieldToString(element)
124 }
125 }
126 default:
127 value = field.String()
128 }
129
130 return value
131}
132
133func getOptsMap() map[string]string {
134 opts := make(map[string]string)

Callers 2

getOptsMapFunction · 0.85
drawRulerFileMethod · 0.85

Calls 2

borderStyleTypeAlias · 0.85
StringMethod · 0.65

Tested by

no test coverage detected