Skip to content

Commit

Permalink
Merge pull request #7 from gregwebs/rm-errors-dep
Browse files Browse the repository at this point in the history
remove errors dependency
  • Loading branch information
gregwebs authored Feb 17, 2025
2 parents 0bf3281 + 32a73bd commit 211fc39
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: setup
uses: actions/setup-go@v4
with:
go-version: '>=1.23.2'
go-version: '>=1.23.6'
cache: false
check-latest: true

Expand Down Expand Up @@ -63,6 +63,6 @@ jobs:
- id: govulncheck
uses: golang/govulncheck-action@v1
with:
go-version-input: 1.23.2
go-version-input: 1.23.6
go-package: ./...
cache: false
22 changes: 20 additions & 2 deletions concurrent.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package concurrent
import (
"sync"

"github.com/gregwebs/errors"
"github.com/gregwebs/go-recovery"
)

Expand Down Expand Up @@ -63,7 +62,7 @@ func (gr GoRoutine) GoN(n int, fn func(int) error) []error {
})
}
wg.Wait()
return errors.Joins(errs...)
return joins(errs...)
}

// The same as [GoEach] but with go routine launching configured by a GoRoutine.
Expand Down Expand Up @@ -168,3 +167,22 @@ func NewUnboundedChan[T any]() UnboundedChan[T] {
}()
return uc
}

func joins(errs ...error) []error {
n := 0
for _, err := range errs {
if err != nil {
n++
}
}
if n == 0 {
return nil
}
newErrs := make([]error, 0, n)
for _, err := range errs {
if err != nil {
newErrs = append(newErrs, err)
}
}
return newErrs
}
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
module github.com/gregwebs/go-concurrent

require github.com/gregwebs/go-recovery v0.3.2
require github.com/gregwebs/go-recovery v0.4.0

require github.com/shoenig/test v1.11.0

require (
github.com/gregwebs/errors v1.14.0
github.com/shoenig/test v1.11.0
github.com/google/go-cmp v0.6.0 // indirect
github.com/gregwebs/stackfmt v0.1.1 // indirect
)

require github.com/google/go-cmp v0.6.0 // indirect

go 1.23.1
go 1.23.6
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ 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/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/gregwebs/errors v1.14.0 h1:bkCLXmqiH+nNXUZi4+CNmDEUq04y9HQg0kNOtNPMS8E=
github.com/gregwebs/errors v1.14.0/go.mod h1:1NkCObP7+scylHlC69lwHl2ACOHwktWYrZV4EJDEl6g=
github.com/gregwebs/go-recovery v0.3.2 h1:vGjQtFXS5lRhDlMlMWCpbm4kQSu2FnZ6ozmxCtCGbJE=
github.com/gregwebs/go-recovery v0.3.2/go.mod h1:q1/QQy0LZN6bIBT90Bc07Xo2ndJEoTc0k8e0l6BN/xY=
github.com/gregwebs/go-recovery v0.4.0 h1:aZPu9Ovka7qHwK+xt/bZOtpaGwRW0ra8dyqiuuyJ0j4=
github.com/gregwebs/go-recovery v0.4.0/go.mod h1:pTiOtRRsvlROffEmTrlpnL6shXjNZflqGibKHpJIW9E=
github.com/gregwebs/stackfmt v0.1.1 h1:bqHZv69OGARsyNPD4tJfkJnu5oWjA86dISQKKfFt98A=
github.com/gregwebs/stackfmt v0.1.1/go.mod h1:MQWvus3s9juULflTEiFIllieKiz7AnX7i4HWyPOs2nQ=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/shoenig/test v1.11.0 h1:NoPa5GIoBwuqzIviCrnUJa+t5Xb4xi5Z+zODJnIDsEQ=
Expand Down
4 changes: 2 additions & 2 deletions group.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ package concurrent

import (
"context"
"errors"
"fmt"
"sync"

"github.com/gregwebs/errors"
"github.com/gregwebs/go-recovery"
)

Expand Down Expand Up @@ -92,7 +92,7 @@ func (g *Group) Wait() []error {
if g.cancel != nil {
g.cancel(errors.Join(errs...))
}
return errors.Joins(errs...)
return joins(errs...)
}

// NewGroupContext constructs a [Group] similar to [x/sync/errgroup] but with aenhancements.
Expand Down

0 comments on commit 211fc39

Please sign in to comment.