File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package plugin
22
33import (
44 "context"
5+ "errors"
56 "fmt"
67
78 "github.com/docker/cli/cli"
@@ -36,17 +37,13 @@ func newRemoveCommand(dockerCli command.Cli) *cobra.Command {
3637}
3738
3839func runRemove (ctx context.Context , dockerCli command.Cli , opts * rmOptions ) error {
39- var errs cli. Errors
40+ var errs error
4041 for _ , name := range opts .plugins {
4142 if err := dockerCli .Client ().PluginRemove (ctx , name , types.PluginRemoveOptions {Force : opts .force }); err != nil {
42- errs = append (errs , err )
43+ errs = errors . Join (errs , err )
4344 continue
4445 }
45- fmt .Fprintln (dockerCli .Out (), name )
46+ _ , _ = fmt .Fprintln (dockerCli .Out (), name )
4647 }
47- // Do not simplify to `return errs` because even if errs == nil, it is not a nil-error interface value.
48- if errs != nil {
49- return errs
50- }
51- return nil
48+ return errs
5249}
Original file line number Diff line number Diff line change 88// Errors is a list of errors.
99// Useful in a loop if you don't want to return the error right away and you want to display after the loop,
1010// all the errors that happened during the loop.
11+ //
12+ // Deprecated: use [errors.Join] instead; will be removed in the next release.
1113type Errors []error
1214
1315func (errList Errors ) Error () string {
You can’t perform that action at this time.
0 commit comments