Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace the deprecated function rand.Seed #358

Closed
cloudxxx8 opened this issue Mar 15, 2023 · 4 comments 路 Fixed by #378
Closed

Replace the deprecated function rand.Seed #358

cloudxxx8 opened this issue Mar 15, 2023 · 4 comments 路 Fixed by #378
Assignees
Labels
1-low priority denoting isolated changes enhancement New feature or request help wanted Extra attention is needed
Projects

Comments

@cloudxxx8
Copy link
Member

馃殌 Feature Request

Relevant Package [REQUIRED]

This feature request is for device-virtual

Description [REQUIRED]

rand.Seed function is deprecated in golang v1.20
https://pkg.go.dev/math/rand#Seed

We had better replace the usage in this repository

Describe the solution you'd like

Try to use Rand.Seed instead
https://pkg.go.dev/math/rand#Rand.Seed

@lenny-goodell
Copy link
Member

@cloudxxx8 , thanks for creating this. There is also other use of math/rand that needs to be replaced also with the seed code.

@cloudxxx8 cloudxxx8 added this to New Issues in Device WG via automation Mar 17, 2023
@cloudxxx8 cloudxxx8 added help wanted Extra attention is needed 1-low priority denoting isolated changes labels Mar 17, 2023
@cloudxxx8
Copy link
Member Author

We should use another random generator

[2023-03-31T01:27:32.857Z] internal/driver/helper.go:121:18: G404: Use of weak random number generator (math/rand instead of crypto/rand) (gosec)
[2023-03-31T01:27:32.857Z] return uint64(rand.Uint32())
[2023-03-31T01:27:32.857Z] ^
[2023-03-31T01:27:32.857Z] internal/driver/helper.go:131:11: G404: Use of weak random number generator (math/rand instead of crypto/rand) (gosec)
[2023-03-31T01:27:32.857Z] return rand.Uint64()

@jinlinGuan
Copy link
Contributor

According to golang/go#54880, the generator is seeded randomly at program startup now. Should we just remove rand.Seed ?

@cloudxxx8
Copy link
Member Author

Yes, please remove it in this case

@lenny-goodell lenny-goodell moved this from New Issues to Release Backlog in Device WG Apr 3, 2023
jinlinGuan added a commit to jinlinGuan/device-virtual-go that referenced this issue Apr 10, 2023
the generator is seeded randomly at program startup now, so remove the Seed function

close edgexfoundry#358

Signed-off-by: Ginny Guan <ginny@iotechsys.com>
jinlinGuan added a commit to jinlinGuan/device-virtual-go that referenced this issue Apr 10, 2023
the generator is seeded randomly at program startup now, so remove the Seed function

close edgexfoundry#358

Signed-off-by: Ginny Guan <ginny@iotechsys.com>

d

Signed-off-by: Ginny Guan <ginny@iotechsys.com>
Device WG automation moved this from Release Backlog to Done Apr 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1-low priority denoting isolated changes enhancement New feature or request help wanted Extra attention is needed
Projects
Device WG
  
Done
Development

Successfully merging a pull request may close this issue.

3 participants