Skip to content

Commit

Permalink
chore: replace go-multierror with stdlib usage (#34)
Browse files Browse the repository at this point in the history
Signed-off-by: Jon Johnson <[email protected]>
  • Loading branch information
jonjohnsonjr authored Jan 5, 2024
1 parent 3e50431 commit 9188275
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
11 changes: 5 additions & 6 deletions eventloop.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"errors"
"os"

"github.com/hashicorp/go-multierror"
"github.com/wagoodman/go-partybus"

"github.com/anchore/go-logger"
Expand Down Expand Up @@ -38,7 +37,7 @@ func eventloop(ctx context.Context, log logger.Logger, subscription *partybus.Su
break
}

var retErr error
var retErr []error
var forceTeardown bool

for {
Expand All @@ -54,7 +53,7 @@ func eventloop(ctx context.Context, log logger.Logger, subscription *partybus.Su
}
if err != nil {
// capture the error from the worker and unsubscribe to complete a graceful shutdown
retErr = multierror.Append(retErr, err)
retErr = append(retErr, err)
if subscription != nil {
_ = subscription.Unsubscribe()
}
Expand Down Expand Up @@ -102,7 +101,7 @@ func eventloop(ctx context.Context, log logger.Logger, subscription *partybus.Su
if errors.Is(err, partybus.ErrUnsubscribe) {
events = nil
} else {
retErr = multierror.Append(retErr, err)
retErr = append(retErr, err)
// TODO: should we unsubscribe? should we try to halt execution? or continue?
}
}
Expand All @@ -123,9 +122,9 @@ func eventloop(ctx context.Context, log logger.Logger, subscription *partybus.Su
}
if ux != nil {
if err := ux.Teardown(forceTeardown); err != nil {
retErr = multierror.Append(retErr, err)
retErr = append(retErr, err)
}
}

return retErr
return errors.Join(retErr...)
}
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ require (
github.com/anchore/fangs v0.0.0-20230807173929-13c94c86f47e
github.com/anchore/go-logger v0.0.0-20230725134548-c21dafa1ec5a
github.com/gookit/color v1.5.4
github.com/hashicorp/go-multierror v1.1.1
github.com/iancoleman/strcase v0.3.0
github.com/pborman/indent v1.2.1
github.com/pkg/profile v1.7.0
Expand All @@ -26,7 +25,6 @@ require (
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/google/pprof v0.0.0-20211214055906-6f57359322fd // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,6 @@ github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5m
github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g=
github.com/gookit/color v1.5.4 h1:FZmqs7XOyGgCAxmWyPslpiok1k05wmY3SJTytgvYFs0=
github.com/gookit/color v1.5.4/go.mod h1:pZJOeOS8DM43rXbp4AZo1n9zCU2qjpcRko0b6/QJi9w=
github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=
github.com/hashicorp/errwrap v1.0.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/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
Expand Down

0 comments on commit 9188275

Please sign in to comment.