From 8ace5844f66a1603dfbfb22442df6cc48a218ae6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Mon, 24 May 2021 00:11:58 +0300 Subject: [PATCH] remove multierr --- internal/cmdlxcconfig/BUILD | 1 - internal/cmdlxcconfig/cmdlxcconfig.go | 15 ++++++++++++--- internal/cmdrootfs/BUILD | 1 - internal/cmdrootfs/cmdrootfs.go | 15 ++++++++++++--- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/internal/cmdlxcconfig/BUILD b/internal/cmdlxcconfig/BUILD index 965205a..0e2a263 100644 --- a/internal/cmdlxcconfig/BUILD +++ b/internal/cmdlxcconfig/BUILD @@ -8,7 +8,6 @@ go_library( deps = [ "//src/undocker/lxcconfig:go_default_library", "@com_github_jessevdk_go_flags//:go_default_library", - "@org_uber_go_multierr//:go_default_library", ], ) diff --git a/internal/cmdlxcconfig/cmdlxcconfig.go b/internal/cmdlxcconfig/cmdlxcconfig.go index 4175983..7511301 100644 --- a/internal/cmdlxcconfig/cmdlxcconfig.go +++ b/internal/cmdlxcconfig/cmdlxcconfig.go @@ -8,7 +8,6 @@ import ( goflags "github.com/jessevdk/go-flags" "github.com/motiejus/code/undocker/lxcconfig" - "go.uber.org/multierr" ) const _description = "Create an LXC-compatible container configuration" @@ -46,7 +45,12 @@ func (c *Command) Execute(args []string) (err error) { if err != nil { return err } - defer func() { err = multierr.Append(err, rd.Close()) }() + defer func() { + err1 := rd.Close() + if err == nil { + err = err1 + } + }() var out io.Writer outf := string(c.PositionalArgs.Outfile) @@ -57,7 +61,12 @@ func (c *Command) Execute(args []string) (err error) { if err != nil { return fmt.Errorf("create: %w", err) } - defer func() { err = multierr.Append(err, outf.Close()) }() + defer func() { + err1 := outf.Close() + if err == nil { + err = err1 + } + }() out = outf } diff --git a/internal/cmdrootfs/BUILD b/internal/cmdrootfs/BUILD index 1fc1680..797e652 100644 --- a/internal/cmdrootfs/BUILD +++ b/internal/cmdrootfs/BUILD @@ -8,7 +8,6 @@ go_library( deps = [ "//src/undocker/rootfs:go_default_library", "@com_github_jessevdk_go_flags//:go_default_library", - "@org_uber_go_multierr//:go_default_library", ], ) diff --git a/internal/cmdrootfs/cmdrootfs.go b/internal/cmdrootfs/cmdrootfs.go index e19ff24..2492e1a 100644 --- a/internal/cmdrootfs/cmdrootfs.go +++ b/internal/cmdrootfs/cmdrootfs.go @@ -8,7 +8,6 @@ import ( goflags "github.com/jessevdk/go-flags" "github.com/motiejus/code/undocker/rootfs" - "go.uber.org/multierr" ) const _description = "Flatten a docker container image to a tarball" @@ -46,7 +45,12 @@ func (c *Command) Execute(args []string) (err error) { if err != nil { return err } - defer func() { err = multierr.Append(err, rd.Close()) }() + defer func() { + err1 := rd.Close() + if err == nil { + err = err1 + } + }() var out io.Writer if fname := string(c.PositionalArgs.Outfile); fname == "-" { @@ -56,7 +60,12 @@ func (c *Command) Execute(args []string) (err error) { if err != nil { return fmt.Errorf("create: %w", err) } - defer func() { err = multierr.Append(err, outf.Close()) }() + defer func() { + err1 = outf.Close() + if err == nil { + err = err1 + } + }() out = outf }