Skip to content

Commit d58a12c

Browse files
refactor: use slices.Contains to simplify (#173)
Signed-off-by: zhedazijingang <[email protected]>
1 parent 27960c8 commit d58a12c

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

pkg/cid/cid.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"encoding/hex"
1212
"encoding/pem"
1313
"fmt"
14+
"slices"
1415

1516
"github.com/hyperledger/fabric-chaincode-go/v2/pkg/attrmgr"
1617
"github.com/hyperledger/fabric-protos-go-apiv2/msp"
@@ -143,12 +144,7 @@ func (c *ClientID) HasOUValue(OUValue string) (bool, error) {
143144
return false, fmt.Errorf("cannot obtain an X509 certificate for the identity")
144145
}
145146

146-
for _, OU := range x509Cert.Subject.OrganizationalUnit {
147-
if OU == OUValue {
148-
return true, nil
149-
}
150-
}
151-
return false, nil
147+
return slices.Contains(x509Cert.Subject.OrganizationalUnit, OUValue), nil
152148
}
153149

154150
// GetX509Certificate returns the X509 certificate associated with the client,

0 commit comments

Comments
 (0)