未验证 提交 9769426e 编写于 作者: C congqixia 提交者: GitHub

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

Signed-off-by: NCongqi Xia <congqi.xia@zilliz.com>
上级 f367249b
......@@ -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))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册