Skip to content

Commit c28e052

Browse files
RiceChuandenyeart
authored andcommitted
chore: use errors.New to replace fmt.Errorf with no parameters
Signed-off-by: RiceChuan <lc582041246@gmail.com>
1 parent 3dd94e1 commit c28e052

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

core/common/ccpackage/ccpackage.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ func ValidateCip(baseCip, otherCip *peer.SignedChaincodeDeploymentSpec) error {
5353
}
5454

5555
if (baseCip.OwnerEndorsements == nil && otherCip.OwnerEndorsements != nil) || (baseCip.OwnerEndorsements != nil && otherCip.OwnerEndorsements == nil) {
56-
return fmt.Errorf("endorsements should either be both nil or not nil")
56+
return errors.New("endorsements should either be both nil or not nil")
5757
}
5858

5959
bN := len(baseCip.OwnerEndorsements)
6060
oN := len(otherCip.OwnerEndorsements)
6161
if bN > 1 || oN > 1 {
62-
return fmt.Errorf("expect utmost 1 endorsement from a owner")
62+
return errors.New("expect utmost 1 endorsement from a owner")
6363
}
6464

6565
if bN != oN {
@@ -79,11 +79,11 @@ func ValidateCip(baseCip, otherCip *peer.SignedChaincodeDeploymentSpec) error {
7979

8080
func createSignedCCDepSpec(cdsbytes []byte, instpolicybytes []byte, endorsements []*peer.Endorsement) (*common.Envelope, error) {
8181
if cdsbytes == nil {
82-
return nil, fmt.Errorf("nil chaincode deployment spec")
82+
return nil, errors.New("nil chaincode deployment spec")
8383
}
8484

8585
if instpolicybytes == nil {
86-
return nil, fmt.Errorf("nil instantiation policy")
86+
return nil, errors.New("nil instantiation policy")
8787
}
8888

8989
// create SignedChaincodeDeploymentSpec...
@@ -160,11 +160,11 @@ func CreateSignedCCDepSpecForInstall(pack []*common.Envelope) (*common.Envelope,
160160
// optionally endorses it
161161
func OwnerCreateSignedCCDepSpec(cds *peer.ChaincodeDeploymentSpec, instPolicy *common.SignaturePolicyEnvelope, owner identity.SignerSerializer) (*common.Envelope, error) {
162162
if cds == nil {
163-
return nil, fmt.Errorf("invalid chaincode deployment spec")
163+
return nil, errors.New("invalid chaincode deployment spec")
164164
}
165165

166166
if instPolicy == nil {
167-
return nil, fmt.Errorf("must provide an instantiation policy")
167+
return nil, errors.New("must provide an instantiation policy")
168168
}
169169

170170
cdsbytes := protoutil.MarshalOrPanic(cds)
@@ -202,7 +202,7 @@ func OwnerCreateSignedCCDepSpec(cds *peer.ChaincodeDeploymentSpec, instPolicy *c
202202
// SignExistingPackage adds a signature to a signed package.
203203
func SignExistingPackage(env *common.Envelope, owner identity.SignerSerializer) (*common.Envelope, error) {
204204
if owner == nil {
205-
return nil, fmt.Errorf("owner not provided")
205+
return nil, errors.New("owner not provided")
206206
}
207207

208208
ch, sdepspec, err := ExtractSignedCCDepSpec(env)
@@ -211,11 +211,11 @@ func SignExistingPackage(env *common.Envelope, owner identity.SignerSerializer)
211211
}
212212

213213
if ch == nil {
214-
return nil, fmt.Errorf("channel header not found in the envelope")
214+
return nil, errors.New("channel header not found in the envelope")
215215
}
216216

217217
if sdepspec == nil || sdepspec.ChaincodeDeploymentSpec == nil || sdepspec.InstantiationPolicy == nil || sdepspec.OwnerEndorsements == nil {
218-
return nil, fmt.Errorf("invalid signed deployment spec")
218+
return nil, errors.New("invalid signed deployment spec")
219219
}
220220

221221
// serialize the signing identity

0 commit comments

Comments
 (0)