MCPcopy Index your code
hub / github.com/perkeep/perkeep / stringFromMixedArray

Function stringFromMixedArray

pkg/schema/schema.go:366–379  ·  view source on GitHub ↗

stringFromMixedArray joins a slice of either strings or float64 values (as retrieved from JSON decoding) into a string. These are used for non-UTF8 filenames in "fileNameBytes" fields. The strings are UTF-8 segments and the float64s (actually uint8 values) are byte values.

(parts []interface{})

Source from the content-addressed store, hash-verified

364// are UTF-8 segments and the float64s (actually uint8 values) are
365// byte values.
366func stringFromMixedArray(parts []interface{}) string {
367 var buf bytes.Buffer
368 for _, part := range parts {
369 if s, ok := part.(string); ok {
370 buf.WriteString(s)
371 continue
372 }
373 if num, ok := part.(float64); ok {
374 buf.WriteByte(byte(num))
375 continue
376 }
377 }
378 return buf.String()
379}
380
381// mixedArrayFromString is the inverse of stringFromMixedArray. It
382// splits a string to a series of either UTF-8 strings and non-UTF-8

Callers 3

SymlinkTargetStringMethod · 0.85
FileNameStringMethod · 0.85
TestStringFromMixedArrayFunction · 0.85

Calls 1

StringMethod · 0.45

Tested by 1

TestStringFromMixedArrayFunction · 0.68