Skip to content

Substitute deprecated rand.Seed() in Go 1.20#231

Merged
samuelkarp merged 1 commit intocontainerd:mainfrom
henry118:rand
Oct 12, 2023
Merged

Substitute deprecated rand.Seed() in Go 1.20#231
samuelkarp merged 1 commit intocontainerd:mainfrom
henry118:rand

Conversation

@henry118
Copy link
Copy Markdown
Member

@henry118 henry118 commented Sep 9, 2023

rand.Seed is deprecated since Go 1.20.

Compiling this package with Go 1.20 resulted in the following linter error:

manifest_test.go:44:2: SA1019: 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. (staticcheck)
rand.Seed(1)
^
make: *** [Makefile:48: lint] Error 1

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