Skip to content

Commit

Permalink
clientv3: add public function to get prefix range end
Browse files Browse the repository at this point in the history
  • Loading branch information
westhood committed Jul 7, 2016
1 parent 234c30c commit 88a9cf2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions clientv3/op.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ func WithSort(target SortTarget, order SortOrder) OpOption {
}
}

// GetPrefixRangeEnd gets the range end of the prefix.
// 'Get(foo, WithPrefix())' is equal to 'Get(foo, WithRange(GetPrefixRangeEnd(foo))'.
func GetPrefixRangeEnd(prefix string) string {
return string(getPrefix([]byte(prefix)))
}

func getPrefix(key []byte) []byte {
end := make([]byte, len(key))
copy(end, key)
Expand Down

0 comments on commit 88a9cf2

Please sign in to comment.