Add handling empty index key that may cause panic issue

pull/6/head
lixiaobing10051267 2016-07-27 21:44:22 +08:00
parent 03fe6b962c
commit a9d631665e
1 changed files with 3 additions and 0 deletions

View File

@ -55,6 +55,9 @@ func IndexFuncToKeyFuncAdapter(indexFunc IndexFunc) KeyFunc {
if len(indexKeys) > 1 {
return "", fmt.Errorf("too many keys: %v", indexKeys)
}
if len(indexKeys) == 0 {
return "", fmt.Errorf("unexpected empty indexKeys")
}
return indexKeys[0], nil
}
}