diff --git a/cmd/neofs-adm/internal/modules/morph/local_client.go b/cmd/neofs-adm/internal/modules/morph/local_client.go index d66b01ebde..7d009663da 100644 --- a/cmd/neofs-adm/internal/modules/morph/local_client.go +++ b/cmd/neofs-adm/internal/modules/morph/local_client.go @@ -318,7 +318,7 @@ func invokeFunction(c Client, h util.Uint160, method string, parameters []any, s script, err := b.Script() if err != nil { - return nil, fmt.Errorf("BUG: invalid parameters for '%s': %v", method, err) + return nil, fmt.Errorf("BUG: invalid parameters for '%s': %w", method, err) } return c.InvokeScript(script, signers) diff --git a/cmd/neofs-adm/internal/modules/morph/notary.go b/cmd/neofs-adm/internal/modules/morph/notary.go index 18dec62a87..181edfaab6 100644 --- a/cmd/neofs-adm/internal/modules/morph/notary.go +++ b/cmd/neofs-adm/internal/modules/morph/notary.go @@ -31,7 +31,7 @@ func depositNotary(cmd *cobra.Command, _ []string) error { w, err := wallet.NewWalletFromFile(p) if err != nil { - return fmt.Errorf("can't open wallet: %v", err) + return fmt.Errorf("can't open wallet: %w", err) } accHash := w.GetChangeAddress() @@ -50,12 +50,12 @@ func depositNotary(cmd *cobra.Command, _ []string) error { prompt := fmt.Sprintf("Enter password for %s >", address.Uint160ToString(accHash)) pass, err := input.ReadPassword(prompt) if err != nil { - return fmt.Errorf("can't get password: %v", err) + return fmt.Errorf("can't get password: %w", err) } err = acc.Decrypt(pass, keys.NEP2ScryptParams()) if err != nil { - return fmt.Errorf("can't unlock account: %v", err) + return fmt.Errorf("can't unlock account: %w", err) } gasStr, err := cmd.Flags().GetString(refillGasAmountFlag) @@ -86,7 +86,7 @@ func depositNotary(cmd *cobra.Command, _ []string) error { height, err := c.GetBlockCount() if err != nil { - return fmt.Errorf("can't get current height: %v", err) + return fmt.Errorf("can't get current height: %w", err) } act, err := actor.New(c, []actor.SignerAccount{{ diff --git a/cmd/neofs-adm/internal/modules/morph/verified_domains.go b/cmd/neofs-adm/internal/modules/morph/verified_domains.go index 12699ef065..caf4e89a0e 100644 --- a/cmd/neofs-adm/internal/modules/morph/verified_domains.go +++ b/cmd/neofs-adm/internal/modules/morph/verified_domains.go @@ -120,7 +120,7 @@ func verifiedNodesDomainSetAccessList(cmd *cobra.Command, _ []string) error { w, err := wallet.NewWalletFromFile(viper.GetString(walletFlag)) if err != nil { - return fmt.Errorf("decode Neo wallet from file: %v", err) + return fmt.Errorf("decode Neo wallet from file: %w", err) } var accAddr util.Uint160 @@ -141,12 +141,12 @@ func verifiedNodesDomainSetAccessList(cmd *cobra.Command, _ []string) error { prompt := fmt.Sprintf("Enter password for %s >", address.Uint160ToString(accAddr)) pass, err := input.ReadPassword(prompt) if err != nil { - return fmt.Errorf("failed to read account password: %v", err) + return fmt.Errorf("failed to read account password: %w", err) } err = acc.Decrypt(pass, keys.NEP2ScryptParams()) if err != nil { - return fmt.Errorf("failed to unlock the account with password: %v", err) + return fmt.Errorf("failed to unlock the account with password: %w", err) } n3Client, err := getN3Client(vpr) diff --git a/cmd/neofs-cli/modules/util/acl.go b/cmd/neofs-cli/modules/util/acl.go index ddc00756ca..59658679d8 100644 --- a/cmd/neofs-cli/modules/util/acl.go +++ b/cmd/neofs-cli/modules/util/acl.go @@ -183,7 +183,7 @@ func ParseEACLRules(table *eacl.Table, rules []string) error { for _, ruleStr := range rules { err := ParseEACLRule(table, ruleStr) if err != nil { - return fmt.Errorf("can't create extended acl record from rule '%s': %v", ruleStr, err) + return fmt.Errorf("can't create extended acl record from rule '%s': %w", ruleStr, err) } } return nil @@ -199,7 +199,7 @@ func ParseEACLRules(table *eacl.Table, rules []string) error { func ParseEACLRule(table *eacl.Table, rule string) error { r, err := shlex.Split(rule) if err != nil { - return fmt.Errorf("can't parse rule '%s': %v", rule, err) + return fmt.Errorf("can't parse rule '%s': %w", rule, err) } return parseEACLTable(table, r) } diff --git a/pkg/core/object/replicate.go b/pkg/core/object/replicate.go index 398d8d5b54..194b99cd0b 100644 --- a/pkg/core/object/replicate.go +++ b/pkg/core/object/replicate.go @@ -54,7 +54,7 @@ func EncodeReplicationMetaInfo(cID cid.ID, oID oid.ID, pSize uint64, // all the errors in the stackitem relate only cases when it is // impossible to use serialized values (too many values, unsupported // types, etc.), unexpected errors at all - panic(fmt.Errorf("unexpected stackitem map serialization failure: %v", err)) + panic(fmt.Errorf("unexpected stackitem map serialization failure: %w", err)) } return result diff --git a/pkg/innerring/internal/blockchain/blockchain.go b/pkg/innerring/internal/blockchain/blockchain.go index 02cb743a81..082fc46f5a 100644 --- a/pkg/innerring/internal/blockchain/blockchain.go +++ b/pkg/innerring/internal/blockchain/blockchain.go @@ -421,7 +421,7 @@ func New(cfg Config) (res *Blockchain, err error) { if err != nil { closeErr := bcStorage.Close() if closeErr != nil { - err = fmt.Errorf("%w; also failed to close blockchain storage: %v", err, closeErr) + err = fmt.Errorf("%w; also failed to close blockchain storage: %w", err, closeErr) } } }() @@ -518,7 +518,7 @@ func (x *Blockchain) Run(ctx context.Context) (err error) { if err != nil { closeErr := x.storage.Close() if closeErr != nil { - err = fmt.Errorf("%w; also failed to close blockchain storage: %v", err, closeErr) + err = fmt.Errorf("%w; also failed to close blockchain storage: %w", err, closeErr) } } }() diff --git a/pkg/local_object_storage/blobstor/fstree/fstree_write_generic.go b/pkg/local_object_storage/blobstor/fstree/fstree_write_generic.go index d51ec8f8c4..3900892511 100644 --- a/pkg/local_object_storage/blobstor/fstree/fstree_write_generic.go +++ b/pkg/local_object_storage/blobstor/fstree/fstree_write_generic.go @@ -60,7 +60,7 @@ func (w *genericWriter) writeData(_ oid.ID, p string, data []byte) error { for i := range retryCount { tmpPath := p + "#" + strconv.FormatUint(uint64(i), 10) err := w.writeAndRename(tmpPath, p, data) - if err != syscall.EEXIST || i == retryCount-1 { + if !errors.Is(err, syscall.EEXIST) || i == retryCount-1 { return err } } @@ -75,11 +75,11 @@ func (w *genericWriter) writeAndRename(tmpPath, p string, data []byte) error { if err != nil { var pe *fs.PathError if errors.As(err, &pe) { - switch pe.Err { - case syscall.ENOSPC: + switch { + case errors.Is(pe.Err, syscall.ENOSPC): err = common.ErrNoSpace _ = os.RemoveAll(tmpPath) - case syscall.EEXIST: + case errors.Is(pe.Err, syscall.EEXIST): return syscall.EEXIST } } diff --git a/pkg/local_object_storage/engine/tree.go b/pkg/local_object_storage/engine/tree.go index 3abe7c3d76..39cdc1ab7d 100644 --- a/pkg/local_object_storage/engine/tree.go +++ b/pkg/local_object_storage/engine/tree.go @@ -20,7 +20,7 @@ func (e *StorageEngine) TreeMove(d pilorama.CIDDescriptor, treeID string, m *pil lm, err := lst[index].TreeMove(d, treeID, m) if err != nil { - if !errors.Is(err, shard.ErrReadOnlyMode) && err != shard.ErrPiloramaDisabled { + if !errors.Is(err, shard.ErrReadOnlyMode) && !errors.Is(err, shard.ErrPiloramaDisabled) { e.reportShardError(lst[index], "can't perform `TreeMove`", err, zap.Stringer("cid", d.CID), zap.String("tree", treeID)) @@ -40,7 +40,7 @@ func (e *StorageEngine) TreeAddByPath(d pilorama.CIDDescriptor, treeID string, a lm, err := lst[index].TreeAddByPath(d, treeID, attr, path, m) if err != nil { - if !errors.Is(err, shard.ErrReadOnlyMode) && err != shard.ErrPiloramaDisabled { + if !errors.Is(err, shard.ErrReadOnlyMode) && !errors.Is(err, shard.ErrPiloramaDisabled) { e.reportShardError(lst[index], "can't perform `TreeAddByPath`", err, zap.Stringer("cid", d.CID), zap.String("tree", treeID)) @@ -59,7 +59,7 @@ func (e *StorageEngine) TreeApply(d pilorama.CIDDescriptor, treeID string, m *pi err = lst[index].TreeApply(d, treeID, m, backgroundSync) if err != nil { - if !errors.Is(err, shard.ErrReadOnlyMode) && err != shard.ErrPiloramaDisabled { + if !errors.Is(err, shard.ErrReadOnlyMode) && !errors.Is(err, shard.ErrPiloramaDisabled) { e.reportShardError(lst[index], "can't perform `TreeApply`", err, zap.Stringer("cid", d.CID), zap.String("tree", treeID)) @@ -76,7 +76,7 @@ func (e *StorageEngine) TreeGetByPath(cid cidSDK.ID, treeID string, attr string, for _, sh := range e.sortShardsByWeight(cid) { nodes, err = sh.TreeGetByPath(cid, treeID, attr, path, latest) if err != nil { - if err == shard.ErrPiloramaDisabled { + if errors.Is(err, shard.ErrPiloramaDisabled) { break } if !errors.Is(err, pilorama.ErrTreeNotFound) { @@ -99,7 +99,7 @@ func (e *StorageEngine) TreeGetMeta(cid cidSDK.ID, treeID string, nodeID piloram for _, sh := range e.sortShardsByWeight(cid) { m, p, err = sh.TreeGetMeta(cid, treeID, nodeID) if err != nil { - if err == shard.ErrPiloramaDisabled { + if errors.Is(err, shard.ErrPiloramaDisabled) { break } if !errors.Is(err, pilorama.ErrTreeNotFound) { @@ -121,7 +121,7 @@ func (e *StorageEngine) TreeGetChildren(cid cidSDK.ID, treeID string, nodeID pil for _, sh := range e.sortShardsByWeight(cid) { nodes, err = sh.TreeGetChildren(cid, treeID, nodeID) if err != nil { - if err == shard.ErrPiloramaDisabled { + if errors.Is(err, shard.ErrPiloramaDisabled) { break } if !errors.Is(err, pilorama.ErrTreeNotFound) { @@ -143,7 +143,7 @@ func (e *StorageEngine) TreeGetOpLog(cid cidSDK.ID, treeID string, height uint64 for _, sh := range e.sortShardsByWeight(cid) { lm, err = sh.TreeGetOpLog(cid, treeID, height) if err != nil { - if err == shard.ErrPiloramaDisabled { + if errors.Is(err, shard.ErrPiloramaDisabled) { break } if !errors.Is(err, pilorama.ErrTreeNotFound) { @@ -164,7 +164,7 @@ func (e *StorageEngine) TreeDrop(cid cidSDK.ID, treeID string) error { for _, sh := range e.sortShardsByWeight(cid) { err = sh.TreeDrop(cid, treeID) if err != nil { - if err == shard.ErrPiloramaDisabled { + if errors.Is(err, shard.ErrPiloramaDisabled) { break } if !errors.Is(err, pilorama.ErrTreeNotFound) && !errors.Is(err, shard.ErrReadOnlyMode) { diff --git a/pkg/local_object_storage/metabase/control.go b/pkg/local_object_storage/metabase/control.go index a984a8deb8..b57b3cf824 100644 --- a/pkg/local_object_storage/metabase/control.go +++ b/pkg/local_object_storage/metabase/control.go @@ -63,7 +63,7 @@ func (db *DB) openBolt() error { return nil }) - if err == errBreakBucketForEach { + if errors.Is(err, errBreakBucketForEach) { db.initialized = true err = nil } diff --git a/pkg/local_object_storage/metabase/list_test.go b/pkg/local_object_storage/metabase/list_test.go index b67ad03a7d..2fa8617f87 100644 --- a/pkg/local_object_storage/metabase/list_test.go +++ b/pkg/local_object_storage/metabase/list_test.go @@ -52,7 +52,7 @@ func benchmarkListWithCursor(b *testing.B, db *meta.DB, batchSize int) { for range b.N { res, err := db.ListWithCursor(prm) if err != nil { - if err != meta.ErrEndOfListing { + if !errors.Is(err, meta.ErrEndOfListing) { b.Fatalf("error: %v", err) } prm.SetCursor(nil) diff --git a/pkg/morph/client/netmap/config.go b/pkg/morph/client/netmap/config.go index f9a8e1159e..7174d603d8 100644 --- a/pkg/morph/client/netmap/config.go +++ b/pkg/morph/client/netmap/config.go @@ -316,7 +316,7 @@ func (c *Client) ReadNetworkConfiguration() (NetworkConfiguration, error) { case EigenTrustAlphaConfig: res.EigenTrustAlpha, err = strconv.ParseFloat(string(value), 64) if err != nil { - return fmt.Errorf("invalid prm %s: %v", EigenTrustAlphaConfig, err) + return fmt.Errorf("invalid prm %s: %w", EigenTrustAlphaConfig, err) } case InnerRingCandidateFeeConfig: res.IRCandidateFee = bytesToUint64(value)