Skip to content

Incorrect use of rand #6134

@HunDunDM

Description

@HunDunDM

Enhancement Task

  • Many packages use the following init functions, which cannot achieve the effect of setting seeds. The Rand object from New is unused.
func init() {
	rand.New(rand.NewSource(time.Now().UnixNano()))
}
  • The global rand function is thread-safe at the cost of having a global write lock. This may cause unexpected performance problems in some places.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/enhancementThe issue or PR belongs to an enhancement.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions