Skip to content

Commit

Permalink
Merge pull request #7 from hicqu/fix-no-index-value
Browse files Browse the repository at this point in the history
fix a bug caused by no index value
  • Loading branch information
disksing authored May 20, 2020
2 parents 41b3d40 + bd949f5 commit bfc1665
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ func main() {
} else {
key = append(key, []byte("_i")...)
key = codec.EncodeInt(key, *indexID)
indexValueInt, err := strconv.ParseInt(*indexValue, 10, 64)
if err != nil {
fmt.Printf("invalid index value: %s\n", *indexValue)
os.Exit(1)
if *indexValue != "" {
indexValueInt, err := strconv.ParseInt(*indexValue, 10, 64)
if err != nil {
fmt.Printf("invalid index value: %s\n", *indexValue)
os.Exit(1)
key = codec.EncodeInt(key, indexValueInt)
}
}
key = codec.EncodeInt(key, indexValueInt)
}

key = codec.EncodeBytes([]byte{}, key)
Expand Down

0 comments on commit bfc1665

Please sign in to comment.