From da6130ebe759f1c4347a3d2313ebc1ac65688405 Mon Sep 17 00:00:00 2001 From: ChengenH Date: Mon, 22 Apr 2024 09:48:15 +0800 Subject: [PATCH] chore: use errors.New to replace fmt.Errorf with no parameters will much better Signed-off-by: ChengenH --- ccaas_builder/cmd/build/main.go | 2 +- ccaas_builder/cmd/detect/main.go | 2 +- ccaas_builder/cmd/release/main.go | 3 ++- discovery/support/config/support.go | 6 +++--- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/ccaas_builder/cmd/build/main.go b/ccaas_builder/cmd/build/main.go index cf574e8c3f1..eff182b7032 100644 --- a/ccaas_builder/cmd/build/main.go +++ b/ccaas_builder/cmd/build/main.go @@ -57,7 +57,7 @@ func main() { func run() error { if len(os.Args) < 4 { - return fmt.Errorf("incorrect number of arguments") + return errors.New("incorrect number of arguments") } sourceDir, metadataDir, outputDir := os.Args[1], os.Args[2], os.Args[3] diff --git a/ccaas_builder/cmd/detect/main.go b/ccaas_builder/cmd/detect/main.go index b35f7e15614..3ad3ccee601 100644 --- a/ccaas_builder/cmd/detect/main.go +++ b/ccaas_builder/cmd/detect/main.go @@ -36,7 +36,7 @@ type chaincodeMetadata struct { func run() error { if len(os.Args) < 3 { - return fmt.Errorf("too few arguments") + return errors.New("too few arguments") } chaincodeMetaData := os.Args[2] diff --git a/ccaas_builder/cmd/release/main.go b/ccaas_builder/cmd/release/main.go index 84f0cd42411..971011c0099 100644 --- a/ccaas_builder/cmd/release/main.go +++ b/ccaas_builder/cmd/release/main.go @@ -7,6 +7,7 @@ SPDX-License-Identifier: Apache-2.0 package main import ( + "errors" "fmt" "io" "log" @@ -48,7 +49,7 @@ func main() { func run() error { if len(os.Args) < 3 { - return fmt.Errorf("incorrect number of arguments") + return errors.New("incorrect number of arguments") } builderOutputDir, releaseDir := os.Args[1], os.Args[2] diff --git a/discovery/support/config/support.go b/discovery/support/config/support.go index c218a47708d..4bd654272c9 100644 --- a/discovery/support/config/support.go +++ b/discovery/support/config/support.go @@ -227,11 +227,11 @@ func appendMSPConfigs(ordererGrp, appGrp map[string]*common.ConfigGroup, output func ValidateConfig(c *common.Config) error { if c.ChannelGroup == nil { - return fmt.Errorf("field Config.ChannelGroup is nil") + return errors.New("field Config.ChannelGroup is nil") } grps := c.ChannelGroup.Groups if grps == nil { - return fmt.Errorf("field Config.ChannelGroup.Groups is nil") + return errors.New("field Config.ChannelGroup.Groups is nil") } for _, field := range []string{channelconfig.OrdererGroupKey, channelconfig.ApplicationGroupKey} { grp, exists := grps[field] @@ -243,7 +243,7 @@ func ValidateConfig(c *common.Config) error { } } if c.ChannelGroup.Values == nil { - return fmt.Errorf("field Config.ChannelGroup.Values is nil") + return errors.New("field Config.ChannelGroup.Values is nil") } return nil }