Browse Source

clientv3: translate WithPrefix() into WithFromKey() for empty key

Anthony Romano 8 years ago
parent
commit
f92c11e1f2
1 changed files with 4 additions and 0 deletions
  1. 4 0
      clientv3/op.go

+ 4 - 0
clientv3/op.go

@@ -282,6 +282,10 @@ func getPrefix(key []byte) []byte {
 // can return 'foo1', 'foo2', and so on.
 // can return 'foo1', 'foo2', and so on.
 func WithPrefix() OpOption {
 func WithPrefix() OpOption {
 	return func(op *Op) {
 	return func(op *Op) {
+		if len(op.key) == 0 {
+			op.key, op.end = []byte{0}, []byte{0}
+			return
+		}
 		op.end = getPrefix(op.key)
 		op.end = getPrefix(op.key)
 	}
 	}
 }
 }