From 70470f9cef751bd108c61bee2f56c24f0f2ac72e Mon Sep 17 00:00:00 2001 From: ferhat elmas Date: Sun, 30 Nov 2025 23:52:06 +0100 Subject: [PATCH] refactor: drop multierror in favor of std Drop github.com/hashicorp/go-multierror in favor of https://pkg.go.dev/errors#Join (go1.20). Related to #11468 Signed-off-by: ferhat elmas --- go.mod | 2 -- go.sum | 1 - pkg/cmd/secret/set/set.go | 8 ++++---- pkg/cmd/variable/set/set.go | 8 ++++---- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index eb8683671..5056df875 100644 --- a/go.mod +++ b/go.mod @@ -30,7 +30,6 @@ require ( github.com/google/go-containerregistry v0.20.6 github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 github.com/gorilla/websocket v1.5.3 - github.com/hashicorp/go-multierror v1.1.1 github.com/hashicorp/go-version v1.7.0 github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec github.com/in-toto/attestation v1.1.2 @@ -154,7 +153,6 @@ require ( github.com/gorilla/css v1.0.1 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2 // indirect github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 // indirect - github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect github.com/henvic/httpretty v0.1.4 // indirect github.com/huandu/xstrings v1.5.0 // indirect diff --git a/go.sum b/go.sum index 3078ae613..71f9982f7 100644 --- a/go.sum +++ b/go.sum @@ -1105,7 +1105,6 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2 h1:8Tjv8EJ+pM1xP8mK6egEbD1OgnV github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2/go.mod h1:pkJQ2tZHJ0aFOVEEot6oZmaVEZcRme73eIFmhiVuRWs= github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw= github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI= -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-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= diff --git a/pkg/cmd/secret/set/set.go b/pkg/cmd/secret/set/set.go index 7fbc77552..40f2fac0d 100644 --- a/pkg/cmd/secret/set/set.go +++ b/pkg/cmd/secret/set/set.go @@ -3,6 +3,7 @@ package set import ( "bytes" "encoding/base64" + "errors" "fmt" "io" "net/http" @@ -18,7 +19,6 @@ import ( "github.com/cli/cli/v2/pkg/cmd/secret/shared" "github.com/cli/cli/v2/pkg/cmdutil" "github.com/cli/cli/v2/pkg/iostreams" - "github.com/hashicorp/go-multierror" "github.com/joho/godotenv" "github.com/spf13/cobra" "golang.org/x/crypto/nacl/box" @@ -295,12 +295,12 @@ func setRun(opts *SetOptions) error { }() } - err = nil + var errs []error cs := opts.IO.ColorScheme() for i := 0; i < len(secrets); i++ { result := <-setc if result.err != nil { - err = multierror.Append(err, result.err) + errs = append(errs, result.err) continue } if result.encrypted != "" { @@ -318,7 +318,7 @@ func setRun(opts *SetOptions) error { } fmt.Fprintf(opts.IO.Out, "%s Set %s secret %s for %s\n", cs.SuccessIcon(), secretApp.Title(), result.key, target) } - return err + return errors.Join(errs...) } type setResult struct { diff --git a/pkg/cmd/variable/set/set.go b/pkg/cmd/variable/set/set.go index 890c1e3fa..57f218221 100644 --- a/pkg/cmd/variable/set/set.go +++ b/pkg/cmd/variable/set/set.go @@ -2,6 +2,7 @@ package set import ( "bytes" + "errors" "fmt" "io" "net/http" @@ -15,7 +16,6 @@ import ( "github.com/cli/cli/v2/pkg/cmd/variable/shared" "github.com/cli/cli/v2/pkg/cmdutil" "github.com/cli/cli/v2/pkg/iostreams" - "github.com/hashicorp/go-multierror" "github.com/joho/godotenv" "github.com/spf13/cobra" ) @@ -201,12 +201,12 @@ func setRun(opts *SetOptions) error { }() } - err = nil + var errs []error cs := opts.IO.ColorScheme() for i := 0; i < len(variables); i++ { result := <-setc if result.Err != nil { - err = multierror.Append(err, result.Err) + errs = append(errs, result.Err) continue } if !opts.IO.IsStdoutTTY() { @@ -222,7 +222,7 @@ func setRun(opts *SetOptions) error { fmt.Fprintf(opts.IO.Out, "%s %s variable %s for %s\n", cs.SuccessIcon(), result.Operation, result.Key, target) } - return err + return errors.Join(errs...) } func getVariablesFromOptions(opts *SetOptions) (map[string]string, error) {