Skip to content

Commit

Permalink
chore: use errors.New to replace fmt.Errorf with no parameters will m…
Browse files Browse the repository at this point in the history
…uch better

Signed-off-by: ChengenH <hce19970702@gmail.com>
  • Loading branch information
ChengenH authored and denyeart committed Apr 22, 2024
1 parent d0bad2e commit da6130e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ccaas_builder/cmd/build/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion ccaas_builder/cmd/detect/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
3 changes: 2 additions & 1 deletion ccaas_builder/cmd/release/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ SPDX-License-Identifier: Apache-2.0
package main

import (
"errors"
"fmt"
"io"
"log"
Expand Down Expand Up @@ -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]
Expand Down
6 changes: 3 additions & 3 deletions discovery/support/config/support.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
}

0 comments on commit da6130e

Please sign in to comment.