Use fmt.Errorf instead of string concat in local_chunk_manager.go (#16442)

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
pull/16549/head
congqixia 2022-04-19 18:39:39 +08:00 committed by GitHub
parent f367249b9e
commit 9769426e84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -18,6 +18,7 @@ package storage
import (
"errors"
"fmt"
"io"
"io/ioutil"
"os"
@ -51,7 +52,7 @@ func NewLocalChunkManager(opts ...Option) *LocalChunkManager {
// Path returns the path of local data if exists.
func (lcm *LocalChunkManager) Path(filePath string) (string, error) {
if !lcm.Exist(filePath) {
return "", errors.New("local file cannot be found with filePath:" + filePath)
return "", fmt.Errorf("local file cannot be found with filePath: %s", filePath)
}
absPath := path.Join(lcm.localPath, filePath)
return absPath, nil
@ -109,7 +110,7 @@ func (lcm *LocalChunkManager) Exist(filePath string) bool {
// Read reads the local storage data if exists.
func (lcm *LocalChunkManager) Read(filePath string) ([]byte, error) {
if !lcm.Exist(filePath) {
return nil, errors.New("file not exist" + filePath)
return nil, fmt.Errorf("file not exist: %s", filePath)
}
absPath := path.Join(lcm.localPath, filePath)
file, err := os.Open(path.Clean(absPath))