Do not rely on string comparison in truncindex
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
This commit is contained in:
parent
9f0f24ea63
commit
ac6d5a4f39
1 changed files with 4 additions and 1 deletions
|
@ -22,6 +22,9 @@ var (
|
||||||
|
|
||||||
// ErrIllegalChar is returned when a space is in the ID
|
// ErrIllegalChar is returned when a space is in the ID
|
||||||
ErrIllegalChar = errors.New("illegal character: ' '")
|
ErrIllegalChar = errors.New("illegal character: ' '")
|
||||||
|
|
||||||
|
// ErrNotExist is returned when ID or its prefix not found in index.
|
||||||
|
ErrNotExist = errors.New("ID does not exist")
|
||||||
)
|
)
|
||||||
|
|
||||||
// TruncIndex allows the retrieval of string identifiers by any of their unique prefixes.
|
// TruncIndex allows the retrieval of string identifiers by any of their unique prefixes.
|
||||||
|
@ -116,7 +119,7 @@ func (idx *TruncIndex) Get(s string) (string, error) {
|
||||||
if id != "" {
|
if id != "" {
|
||||||
return id, nil
|
return id, nil
|
||||||
}
|
}
|
||||||
return "", fmt.Errorf("no such id: %s", s)
|
return "", ErrNotExist
|
||||||
}
|
}
|
||||||
|
|
||||||
// Iterate iterates over all stored IDs, and passes each of them to the given handler.
|
// Iterate iterates over all stored IDs, and passes each of them to the given handler.
|
||||||
|
|
Loading…
Reference in a new issue