Skip to content

Commit

Permalink
throw error if key isn't found
Browse files Browse the repository at this point in the history
  • Loading branch information
abdulsattar committed Feb 17, 2024
1 parent 6fa5793 commit 88fdddf
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"encoding/binary"
"errors"
"io"
"os"
)
Expand Down Expand Up @@ -75,10 +76,7 @@ func (kv *KV) Close() error {
func (kv *KV) Get(key string) (string, error) {
keyDir, exists := kv.index[key]
if !exists {
err := buildIndex(kv)
if err != nil {
return "", err
}
return "", errors.New("key Not found")
}
return readAt(kv.file, keyDir.valueOffset, keyDir.valueSize)
}
Expand Down

0 comments on commit 88fdddf

Please sign in to comment.