From 73b21dd6d5dda5f584eb87ab0fd2f0fac8b20f35 Mon Sep 17 00:00:00 2001 From: RiceChuan Date: Thu, 12 Dec 2024 17:24:46 +0800 Subject: [PATCH] chore: use errors.New to replace fmt.Errorf with no parameters (#1015) Signed-off-by: RiceChuan --- nodedb.go | 4 ++-- nodedb_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nodedb.go b/nodedb.go index 10c5546d1..f997596a8 100644 --- a/nodedb.go +++ b/nodedb.go @@ -204,7 +204,7 @@ func (ndb *nodeDB) GetFastNode(key []byte) (*fastnode.Node, error) { defer ndb.mtx.Unlock() if len(key) == 0 { - return nil, fmt.Errorf("nodeDB.GetFastNode() requires key, len(key) equals 0") + return nil, errors.New("nodeDB.GetFastNode() requires key, len(key) equals 0") } if cachedFastNode := ndb.fastNodeCache.Get(key); cachedFastNode != nil { @@ -1338,4 +1338,4 @@ func (ndb *nodeDB) String() (string, error) { return "-" + "\n" + buf.String() + "-", nil } -var ErrNodeMissingNodeKey = fmt.Errorf("node does not have a nodeKey") +var ErrNodeMissingNodeKey = errors.New("node does not have a nodeKey") diff --git a/nodedb_test.go b/nodedb_test.go index 170261110..f87103025 100644 --- a/nodedb_test.go +++ b/nodedb_test.go @@ -278,7 +278,7 @@ func TestTraverseNodes(t *testing.T) { return err } if actualNode.String() != node.String() { - return fmt.Errorf("found unexpected node") + return errors.New("found unexpected node") } count++ return nil