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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace golang.org/x/exp with stdlib #759

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Juneezee
Copy link

@Juneezee Juneezee commented Mar 9, 2025

These experimental packages are now available in the Go standard library.

  1. golang.org/x/exp/slices -> slices (https://go.dev/doc/go1.21#slices)
  2. golang.org/x/exp/rand -> math/rand/v2 (https://go.dev/doc/go1.22#math_rand_v2)

golang.org/x/exp/rand has been deprecated and scheduled to be deleted.

Reference: golang/exp@f9890c6

These experimental packages are now available in the Go standard
library.

	1. golang.org/x/exp/slices -> slices [1]
	2. golang.org/x/exp/rand -> math/rand/v2 [2]

golang.org/x/exp/rand has been deprecated and scheduled to be deleted [3].

[1]: https://go.dev/doc/go1.21#slices
[2]: https://go.dev/doc/go1.22#math_rand_v2
[3]: golang/exp@f9890c6

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
@adambabik
Copy link
Collaborator

Thanks for the contribution! I requested to stay with math/rand, because it will result in simpler code. The rest looks fine.

Juneezee added a commit to Juneezee/runme that referenced this pull request Mar 9, 2025
Reference: stateful#759 (review)
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
@Juneezee Juneezee requested a review from adambabik March 9, 2025 08:39
Reference: stateful#759 (review)
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
It uses math/rand and LockedMonotonicReader internally, which is exactly
the same code as ours.

Reference: https://github.com/oklog/ulid/blob/v2.1.0/ulid.go#L132-L140
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
@@ -60,7 +37,7 @@ func GenerateID() string {
}

func DefaultGenerator() string {
entropy := DefaultEntropy()
entropy := ulid.DefaultEntropy()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After applying the code suggestion #759 (comment), I realize that we can use the DefaultEntropy() function from github.com/oklog/ulid/v2 since it also uses math/rand and LockedMonotonicReader internally.

https://github.com/oklog/ulid/blob/v2.1.0/ulid.go#L132-L140

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