From f1193effc0c2ae7bf9660e61dd54c441693ba462 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 3 Feb 2025 19:36:59 +0100 Subject: [PATCH] cli/command/service: use errors.Join Use stdlib multi-errors instead of creating our own Signed-off-by: Sebastiaan van Stijn --- cli/command/service/remove.go | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/cli/command/service/remove.go b/cli/command/service/remove.go index a191aa97bf..a07ee36bff 100644 --- a/cli/command/service/remove.go +++ b/cli/command/service/remove.go @@ -2,12 +2,11 @@ package service import ( "context" + "errors" "fmt" - "strings" "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" - "github.com/pkg/errors" "github.com/spf13/cobra" ) @@ -32,17 +31,13 @@ func newRemoveCommand(dockerCli command.Cli) *cobra.Command { func runRemove(ctx context.Context, dockerCLI command.Cli, serviceIDs []string) error { apiClient := dockerCLI.Client() - var errs []string + var errs []error for _, id := range serviceIDs { - err := apiClient.ServiceRemove(ctx, id) - if err != nil { - errs = append(errs, err.Error()) + if err := apiClient.ServiceRemove(ctx, id); err != nil { + errs = append(errs, err) continue } _, _ = fmt.Fprintln(dockerCLI.Out(), id) } - if len(errs) > 0 { - return errors.New(strings.Join(errs, "\n")) - } - return nil + return errors.Join(errs...) }