MCPcopy Create free account
hub / github.com/google/gapid / stringify

Function stringify

gapil/template/strings.go:36–68  ·  view source on GitHub ↗

stringify transforms the input parameters into a string list. Arrays and slices are flattened into a sequential list of strings.

(v ...interface{})

Source from the content-addressed store, hash-verified

34// stringify transforms the input parameters into a string list. Arrays and
35// slices are flattened into a sequential list of strings.
36func stringify(v ...interface{}) stringList {
37 out := stringList{}
38 for _, v := range v {
39 switch v := v.(type) {
40 case nil:
41 case string:
42 out = append(out, v)
43 case []string:
44 out = append(out, v...)
45 case stringList:
46 out = append(out, v...)
47 default:
48 switch reflect.TypeOf(v).Kind() {
49 case reflect.Array, reflect.Slice:
50 v := reflect.ValueOf(v)
51 for i, c := 0, v.Len(); i < c; i++ {
52 out = append(out, stringify(v.Index(i).Interface())...)
53 }
54 default:
55 out = append(out, fmt.Sprintf("%v", v))
56 }
57 }
58 }
59 // Filter out any empty strings
60 count := 0
61 for _, s := range out {
62 if len(s) > 0 {
63 out[count] = s
64 count++
65 }
66 }
67 return out[:count]
68}
69
70// Strings returns the arguments as a string list.
71func (Functions) Strings(v ...interface{}) stringList {

Callers 15

StringsMethod · 0.85
JoinWithMethod · 0.85
SplitOnMethod · 0.85
SplitUpperCaseMethod · 0.85
SplitPascalCaseMethod · 0.85
TitleMethod · 0.85
UntitleMethod · 0.85
LowerMethod · 0.85
UpperMethod · 0.85
ContainsMethod · 0.85
ReplaceMethod · 0.85
TrimLeftMethod · 0.85

Calls 5

InterfaceMethod · 0.80
KindMethod · 0.65
LenMethod · 0.65
IndexMethod · 0.65
TypeOfMethod · 0.45

Tested by 2

TestJoinWithFunction · 0.68
ExamplestringList_StringFunction · 0.68