Skip to content

Commit aa96cb7

Browse files
committed
cli/command/volume: use errors.Join
Use stdlib multi-errors instead of creating our own Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent be985bd commit aa96cb7

1 file changed

Lines changed: 4 additions & 10 deletions

File tree

cli/command/volume/remove.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ package volume
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
6-
"strings"
77

88
"github.com/docker/cli/cli"
99
"github.com/docker/cli/cli/command"
1010
"github.com/docker/cli/cli/command/completion"
11-
"github.com/pkg/errors"
1211
"github.com/spf13/cobra"
1312
)
1413

@@ -43,18 +42,13 @@ func newRemoveCommand(dockerCli command.Cli) *cobra.Command {
4342
func runRemove(ctx context.Context, dockerCLI command.Cli, opts *removeOptions) error {
4443
apiClient := dockerCLI.Client()
4544

46-
var errs []string
47-
45+
var errs []error
4846
for _, name := range opts.volumes {
4947
if err := apiClient.VolumeRemove(ctx, name, opts.force); err != nil {
50-
errs = append(errs, err.Error())
48+
errs = append(errs, err)
5149
continue
5250
}
5351
_, _ = fmt.Fprintln(dockerCLI.Out(), name)
5452
}
55-
56-
if len(errs) > 0 {
57-
return errors.Errorf("%s", strings.Join(errs, "\n"))
58-
}
59-
return nil
53+
return errors.Join(errs...)
6054
}

0 commit comments

Comments
 (0)