From 227b8ed499a93068e3dfd60eff5dbf395582a722 Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Sat, 12 Aug 2023 16:03:35 +0900 Subject: [PATCH] Remove dependency on github.com/hashicorp/go-multierror Signed-off-by: Akihiro Suda --- go.mod | 2 -- go.sum | 5 ----- pkg/util/util.go | 14 ++++++++------ 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/go.mod b/go.mod index 679cdc8..3fda16c 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,6 @@ module github.com/lima-vm/sshocker go 1.20 require ( - github.com/hashicorp/go-multierror v1.1.1 github.com/pkg/sftp v1.13.5 github.com/sirupsen/logrus v1.9.3 github.com/urfave/cli/v2 v2.25.7 @@ -11,7 +10,6 @@ require ( require ( github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect - github.com/hashicorp/errwrap v1.1.0 // indirect github.com/kr/fs v0.1.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect diff --git a/go.sum b/go.sum index c547103..129a170 100644 --- a/go.sum +++ b/go.sum @@ -3,11 +3,6 @@ github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46t github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= -github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= -github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/kr/fs v0.1.0 h1:Jskdu9ieNAYnjxsi0LbQp1ulIKZV1LAFgK1tWhpZgl8= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/pkg/sftp v1.13.5 h1:a3RLUqkyjYRtBTZJZ1VRrKbN3zhuPLlUc3sphVz81go= diff --git a/pkg/util/util.go b/pkg/util/util.go index 54a3701..6c5001f 100644 --- a/pkg/util/util.go +++ b/pkg/util/util.go @@ -1,9 +1,8 @@ package util import ( + "errors" "io" - - "github.com/hashicorp/go-multierror" ) // RWC composes io.ReadCloser and io.WriteCloser into io.ReadWriteCloser @@ -13,12 +12,15 @@ type RWC struct { } func (rwc *RWC) Close() error { - var merr *multierror.Error + var merr error if err := rwc.ReadCloser.Close(); err != nil { - merr = multierror.Append(merr, err) + merr = errors.Join(merr, err) } if err := rwc.WriteCloser.Close(); err != nil { - merr = multierror.Append(merr, err) + merr = errors.Join(merr, err) + } + if merr != nil { + return merr } - return merr.ErrorOrNil() + return nil }