diff --git a/cli/command/plugin/remove.go b/cli/command/plugin/remove.go index 2614cab3ac..36b0013105 100644 --- a/cli/command/plugin/remove.go +++ b/cli/command/plugin/remove.go @@ -2,6 +2,7 @@ package plugin import ( "context" + "errors" "fmt" "github.com/docker/cli/cli" @@ -36,17 +37,13 @@ func newRemoveCommand(dockerCli command.Cli) *cobra.Command { } func runRemove(ctx context.Context, dockerCli command.Cli, opts *rmOptions) error { - var errs cli.Errors + var errs error for _, name := range opts.plugins { if err := dockerCli.Client().PluginRemove(ctx, name, types.PluginRemoveOptions{Force: opts.force}); err != nil { - errs = append(errs, err) + errs = errors.Join(errs, err) continue } - fmt.Fprintln(dockerCli.Out(), name) + _, _ = fmt.Fprintln(dockerCli.Out(), name) } - // Do not simplify to `return errs` because even if errs == nil, it is not a nil-error interface value. - if errs != nil { - return errs - } - return nil + return errs }