Skip to content
Snippets Groups Projects
Commit e52d84a8 authored by AJ Yoo's avatar AJ Yoo Committed by Anthony Yoo
Browse files

key: Add slice key stringification

Change-Id: I0dd855c771a91f7f12dbba06560d8e973ded4881
parent b9cf994f
No related branches found
No related tags found
No related merge requests found
......@@ -69,7 +69,12 @@ func StringifyInterface(key interface{}) (string, error) {
keys[i] = stringify(k) + "=" + stringify(m[k])
}
str = strings.Join(keys, "_")
case []interface{}:
elements := make([]string, len(key))
for i, element := range key {
elements[i] = stringify(element)
}
str = strings.Join(elements, ",")
case value.Value:
return key.String(), nil
......
......@@ -119,6 +119,18 @@ func TestStringify(t *testing.T) {
"n": nil,
},
output: "Unable to stringify nil",
}, {
name: "[]interface{}",
input: []interface{}{
uint32(42),
true,
"foo",
map[Key]interface{}{
New("a"): "b",
New("b"): "c",
},
},
output: "42,true,foo,a=b_b=c",
}}
for _, tcase := range testcases {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment