remove multierr

This commit is contained in:
Motiejus Jakštys 2021-05-24 00:11:58 +03:00
parent 9319fec6f8
commit 8ace5844f6
4 changed files with 24 additions and 8 deletions

View File

@ -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",
],
)

View File

@ -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
}

View File

@ -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",
],
)

View File

@ -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
}