Skip to content

Commit

Permalink
Remove circular dependency on github.com/bobg/seqs. (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
bobg authored Jan 14, 2025
1 parent f18430b commit 37e4a61
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
4 changes: 0 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,4 @@ go 1.23

require golang.org/x/sync v0.8.0

require github.com/bobg/seqs v1.2.0

require github.com/bobg/go-generics/v3 v3.7.0 // indirect

retract v4.0.0
8 changes: 0 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,10 +1,2 @@
github.com/bobg/go-generics/v3 v3.7.0 h1:4SJHDWqONTRcA8al6491VW/ys6061bPCcTcI7YnIHPc=
github.com/bobg/go-generics/v3 v3.7.0/go.mod h1:wGlMLQER92clsh3cJoQjbUtUEJ03FoxnGhZjaWhf4fM=
github.com/bobg/seqs v1.2.0 h1:y9SS1zisfkNQepd+xia/3ELDYR4T4vuLTyCA4UVOiKA=
github.com/bobg/seqs v1.2.0/go.mod h1:icgB+vXIoU6s675tLYVAgcUYry1PkYwgEKvzOuFemOk=
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/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
14 changes: 11 additions & 3 deletions parallel/parallel.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import (
"sync"

"golang.org/x/sync/errgroup"

"github.com/bobg/seqs"
)

// Error is an error type for wrapping errors returned from worker goroutines.
Expand Down Expand Up @@ -103,7 +101,17 @@ func Producers[T any](ctx context.Context, n int, f func(context.Context, int, f
close(ch)
}()

return seqs.FromChan(ch), &err
// This could be FromSeq(ch),
// but that would introduce a circular dependency on github.com/bobg/seqs.
fromSeq := func(yield func(T) bool) {
for x := range ch {
if !yield(x) {
return
}
}
}

return fromSeq, &err
}

// Consumers launches n parallel workers each consuming values supplied by the caller.
Expand Down

0 comments on commit 37e4a61

Please sign in to comment.