From 54039cad89454f092b12cedf6caf62e7a7500fb6 Mon Sep 17 00:00:00 2001 From: Daniel Milchev Date: Wed, 22 Nov 2023 15:26:03 +0200 Subject: [PATCH] [#210] Fixed lint suggestions. --- containerm/cli/cli_command_ctrs_remove.go | 22 +++++++++++----------- containerm/util/error/error_util.go | 1 + 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/containerm/cli/cli_command_ctrs_remove.go b/containerm/cli/cli_command_ctrs_remove.go index b6d2b81..73fb12c 100644 --- a/containerm/cli/cli_command_ctrs_remove.go +++ b/containerm/cli/cli_command_ctrs_remove.go @@ -59,21 +59,21 @@ func (cc *removeCmd) run(args []string) error { return err } return cc.cli.gwManClient.Remove(ctx, ctr.ID, cc.config.force) - } else { - for _, arg := range args { - ctr, err = utilcli.ValidateContainerByNameArgsSingle(ctx, []string{arg}, cc.config.name, cc.cli.gwManClient) - if err == nil { - if err = cc.cli.gwManClient.Remove(ctx, ctr.ID, cc.config.force); err != nil { - errs.Append(err) - } - } else { + } + for _, arg := range args { + ctr, err = utilcli.ValidateContainerByNameArgsSingle(ctx, []string{arg}, cc.config.name, cc.cli.gwManClient) + if err == nil { + if err = cc.cli.gwManClient.Remove(ctx, ctr.ID, cc.config.force); err != nil { errs.Append(err) } - } - if errs.Size() > 0 { - return errors.New(errs.ErrorWithMessage("containers couldn't be removed due to the following reasons: ")) + } else { + errs.Append(err) } } + if errs.Size() > 0 { + return errors.New(errs.ErrorWithMessage("containers couldn't be removed due to the following reasons: ")) + } + return nil } diff --git a/containerm/util/error/error_util.go b/containerm/util/error/error_util.go index 61d5e8f..abd9809 100644 --- a/containerm/util/error/error_util.go +++ b/containerm/util/error/error_util.go @@ -37,6 +37,7 @@ func (m *CompoundError) Error() string { return m.ErrorWithMessage(fmt.Sprintf("%d errors:", len(m.errs))) } +// ErrorWithMessage returns combined error messages with a custom message. func (m *CompoundError) ErrorWithMessage(message string) string { if len(m.errs) == 0 { return fmt.Sprintf("no error")