Made with switch
@@ -288,30 +288,37 @@ func processCreateIndex(sess *mgo.Session, buf []byte) error {
for _, key := range opdoc.O.Key {
sign := ""
- if intKey, ok := key.Value.(int); ok && intKey < 0 {
+ switch k := key.Value.(type) {
+ case int:
+ if k < 0 {
sign = "-"
}
- if int8Key, ok := key.Value.(int8); ok && int8Key < 0 {
+ case int8:
+ if k < 0 {
sign = "-"
}
- if int16Key, ok := key.Value.(int16); ok && int16Key < 0 {
+ case int16:
+ if k < 0 {
sign = "-"
}
- if int32Key, ok := key.Value.(int32); ok && int32Key < 0 {
+ case int32:
+ if k < 0 {
sign = "-"
}
- if int64Key, ok := key.Value.(int64); ok && int64Key < 0 {
+ case int64:
+ if k < 0 {
sign = "-"
}
- if float32Key, ok := key.Value.(float32); ok && float32Key < 0 {
+ case float32:
+ if k < 0 {
sign = "-"
}
- if floatKey, ok := key.Value.(float64); ok && floatKey < 0 {
+ case float64:
+ if k < 0 {
sign = "-"
}
-
+ }
index.Key = append(index.Key, sign+key.Name)
-
}
err := sess.DB(ns).C(opdoc.O.CreateIndexes).EnsureIndex(index)
if err != nil {
