JoinTo writes the given slice of values delimited by the provided delimiter to the given SafeWriter.
(w SafeWriter, delim RedactableString, values interface{})
| 24 | // JoinTo writes the given slice of values delimited by the provided |
| 25 | // delimiter to the given SafeWriter. |
| 26 | func 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 |
searching dependent graphs…