MCPcopy Create free account
hub / github.com/cockroachdb/redact / JoinTo

Function JoinTo

util.go:26–40  ·  view source on GitHub ↗

JoinTo writes the given slice of values delimited by the provided delimiter to the given SafeWriter.

(w SafeWriter, delim RedactableString, values interface{})

Source from the content-addressed store, hash-verified

24// JoinTo writes the given slice of values delimited by the provided
25// delimiter to the given SafeWriter.
26func JoinTo(w SafeWriter, delim RedactableString, values interface{}) {
27 // Ideally, we'd make the interface clearer: JoinTo is a generic function,
28 // with a "values" argument of type []T where T is a type variable.
29 v := reflect.ValueOf(values)
30 if v.Kind() != reflect.Slice {
31 // Note a slice: just print the value as-is.
32 w.Print(values)
33 }
34 for i, l := 0, v.Len(); i < l; i++ {
35 if i > 0 {
36 w.Print(delim)
37 }
38 w.Print(v.Index(i).Interface())
39 }
40}
41
42// Join creates a redactable string from the
43// given slice of redactable strings, adjoined

Callers 2

TestJoinToFunction · 0.85
JoinFunction · 0.85

Calls 2

PrintMethod · 0.65
LenMethod · 0.45

Tested by 1

TestJoinToFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…