From aa96cb7aa0479062e96ecd315e830c22e082fe34 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 3 Feb 2025 19:38:27 +0100 Subject: [PATCH] cli/command/volume: use errors.Join Use stdlib multi-errors instead of creating our own Signed-off-by: Sebastiaan van Stijn --- cli/command/volume/remove.go | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/cli/command/volume/remove.go b/cli/command/volume/remove.go index 1eb3887347..eab894b02b 100644 --- a/cli/command/volume/remove.go +++ b/cli/command/volume/remove.go @@ -2,13 +2,12 @@ package volume import ( "context" + "errors" "fmt" - "strings" "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" "github.com/docker/cli/cli/command/completion" - "github.com/pkg/errors" "github.com/spf13/cobra" ) @@ -43,18 +42,13 @@ func newRemoveCommand(dockerCli command.Cli) *cobra.Command { func runRemove(ctx context.Context, dockerCLI command.Cli, opts *removeOptions) error { apiClient := dockerCLI.Client() - var errs []string - + var errs []error for _, name := range opts.volumes { if err := apiClient.VolumeRemove(ctx, name, opts.force); err != nil { - errs = append(errs, err.Error()) + errs = append(errs, err) continue } _, _ = fmt.Fprintln(dockerCLI.Out(), name) } - - if len(errs) > 0 { - return errors.Errorf("%s", strings.Join(errs, "\n")) - } - return nil + return errors.Join(errs...) }