Skip to content

fix: replace rand.seed method to support golang 1.20#1343

Merged
stephenafamo merged 1 commit intoaarondl:masterfrom
pbr0ck3r:pbr0cker/fix/refactor-rand-seed
Jan 21, 2024
Merged

fix: replace rand.seed method to support golang 1.20#1343
stephenafamo merged 1 commit intoaarondl:masterfrom
pbr0ck3r:pbr0cker/fix/refactor-rand-seed

Conversation

@pbr0ck3r
Copy link

@pbr0ck3r pbr0ck3r commented Jan 21, 2024

What this PR does / why we need it

  • Replace rand.seed(1) method to be rand.New(rand.NewSource(1)) in order to allow sqlboiler to generate code compatible with Golang 1.20. Ensured methods exist in Golang 1.16, https://pkg.go.dev/math/rand@go1.16

staticcheck error:

 rand.Seed has been deprecated since Go 1.20 and an alternative has been available since Go 1.0: Programs that call Seed and then expect a specific sequence of results from the global random source (using functions such as Int) can be broken when a dependency changes how much it consumes from the global random source. To avoid such breakages, programs that need a specific result sequence should use NewRand(NewSource(seed)) to obtain a random generator that other packages cannot access.  (SA1019)

@pbr0ck3r pbr0ck3r changed the title fix: update rand.seed method to support with golang 1.20 fix: update rand.seed method to support golang 1.20 Jan 21, 2024
@pbr0ck3r pbr0ck3r changed the title fix: update rand.seed method to support golang 1.20 fix: replace rand.seed method to support golang 1.20 Jan 21, 2024
@stephenafamo stephenafamo merged commit 0ccf00c into aarondl:master Jan 21, 2024
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.

2 participants