Skip to content

modernise with go fix, drop deprecated rand.Seed - #10

Merged
umputun merged 1 commit into
masterfrom
modernise-go-fix
Aug 19, 2026
Merged

modernise with go fix, drop deprecated rand.Seed#10
umputun merged 1 commit into
masterfrom
modernise-go-fix

Conversation

@paskal

@paskal paskal commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

go fix ./... plus the two places the go tool skips, README.md and _example/, which is excluded by its leading underscore:

  • interface{} becomes any
  • counted loops become range over int
  • the ch := ch loop variable copies go, obsolete since go 1.22

Also drops the deprecated rand.Seed call, the global source has been seeded randomly since go 1.20, and preallocates outChs, which prealloc flags once the loop count is known.

any is an alias for interface{}, so there is no API change here.

This one rewrites most lines in the repo, so merge it after #5, #7, #9 and #11 and I will rerun the sweep on top rather than leaving the conflicts to sort out by hand.

@paskal
paskal requested a review from umputun as a code owner August 19, 2026 05:04
@coveralls

coveralls commented Aug 19, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 32225786380

Coverage decreased (-0.9%) to 89.722%

Details

  • Coverage decreased (-0.9%) from the base build.
  • Patch coverage: 1 uncovered change across 1 file (30 of 31 lines covered, 96.77%).
  • 4 coverage regressions across 1 file.

Uncovered Changes

File Changed Covered %
flow.go 12 11 91.67%
Total (6 files) 31 30 96.77%

Coverage Regressions

4 previously-covered lines in 1 file lost coverage.

File Lines Losing Coverage Coverage
pool/pool.go 4 92.07%

Coverage Stats

Coverage Status
Relevant Lines: 467
Covered Lines: 419
Line Coverage: 89.72%
Coverage Strength: 2727.01 hits per line

💛 - Coveralls

@umputun

umputun commented Aug 19, 2026

Copy link
Copy Markdown
Member

this needs a rebase, and it isn't a clean one: the branch predates #5 and #9, so both conflicting files would come back wrong.

README.md is the awkward one. #9 corrected those examples, and this branch still has the originals with any substituted in, so the typos come back with it, store WorkerStore} instead of ), pool.Sender instead of pool.SenderFn, and cursor(ctx, &v) instead of cursor.Next(ctx, &v).

pool/pool.go is the one I didn't want to touch by hand: #5 added bufLock, abortCh and the sync import for the Submit deadlock and the batch buffer race, and none of that is on this branch.

I tried the rebase and backed out rather than resolve it for you, since picking sides there could quietly drop the concurrency fix. Redoing the interface{} to any pass against current master is probably less work than untangling it, whichever you prefer.

not blocking the release, v1.3.3 is going out with #7, #8 and #9, since #7 fixes a Wait deadlock that's live in v1.3.2.

@umputun

umputun commented Aug 19, 2026

Copy link
Copy Markdown
Member

conflicting again, and that one is on me: I merged #11 before this, and both touch flow_test.go, so your rebase was undone within the hour. Should have taken this one first since it was the older and purely mechanical of the two.

rather than a third rebase, re-running go fix against current master is probably a minute's work and gives a clean diff. Two things beyond the mechanical rewrite that this branch carried, so they do not get lost: dropping rand.Seed(time.Now().UnixNano()) with its time import, and removing the ch := ch capture workaround.

no rush, nothing depends on it.

go fix ./... replaces interface{} with any, rewrites counted loops as
range over int and removes the ch := ch capture obsolete since go 1.22.
README and _example are swept by hand as the go tool skips them.

rand.Seed is deprecated and no longer needed, the global source is
seeded randomly since go 1.20, its time import goes with it. outChs
preallocated as the rewritten loop makes the capacity known, flagged
by prealloc.
@paskal

paskal commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

Rebuilt from current master instead of rebasing, as you suggested. The branch is now a single commit on top of 12bf64e, no history from before #5.

go fix ./... output plus a hand sweep of README.md and _example/, which the go tool skips. It also removes the ch := ch capture on its own now, so that came for free. The two non-mechanical bits from the old branch are carried over: rand.Seed(time.Now().UnixNano()) is gone along with its time import, and outChs is preallocated, which prealloc starts flagging once the loop is a range over a known count.

Both things you flagged are checked rather than assumed:

  • pool/pool.go: bufLock, abortCh, the sync import and the locking in Submit are untouched. The only change in that area is send taking []any instead of []interface{}.
  • README.md: pool.SenderFn, cursor.Next and the WorkerFn signature from fix pool section of README #9 all survive, only the type spelling changed. I extract both snippets into a scratch module and build them against the package, so they compile rather than just look right.

On the dependency update, there is nothing to take. testify v1.12.0 and yaml.v3 v3.0.1 are the latest releases, and x/sync stops at v0.11.0 because v0.12.0 declares go 1.23.0, which go orders above our go 1.23 and rewrites the directive. go get -u ./... proposes exactly one change, x/sync to v0.22.0, and takes the directive to 1.25.0 with it, so it is skipped. go mod tidy and go get -u=patch both leave go.mod and go.sum unchanged.

go test -race ./... and golangci-lint run are green. The only red check is coveralls at -0.04%, which is the deleted rand.Seed line, one covered line out of 467.

@umputun
umputun merged commit 1a6a3a4 into master Aug 19, 2026
5 of 7 checks passed
@umputun
umputun deleted the modernise-go-fix branch August 19, 2026 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants