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

Add optional seed argument to shuffle #9247

Closed
bep opened this issue Dec 4, 2021 · 4 comments
Closed

Add optional seed argument to shuffle #9247

bep opened this issue Dec 4, 2021 · 4 comments
Milestone

Comments

@bep
Copy link
Member

bep commented Dec 4, 2021

See https://discourse.gohugo.io/t/make-shuffle-show-different-posts-per-post/35900

@bep bep added the Enhancement label Dec 4, 2021
@bep bep added this to the v0.90 milestone Dec 4, 2021
@jmooring
Copy link
Member

jmooring commented Dec 4, 2021

The lack of randomization in the referenced forum topic was due to a cached partial.

The current shuffle seed is time.Now().UTC().UnixNano().

  1. The UTC() conversion is not necessary.
  2. I don't understand how shuffle random seed #4337 had any beneficial effect.
  3. Are there cases where the current seed is insufficient?

I'm not against adding an arg, I just haven't encountered a problem with this before.

@bep
Copy link
Member Author

bep commented Dec 5, 2021

Are there cases where the current seed is insufficient?

The current seed is fine, but there are 2 situations where I imagine a custom seed would be useful.

  1. If you want a more stable shuffle (same order on every build), just pass in 42 or something as the seed.
  2. You want new shuffle on each build, but slightly different between the sections ...

@bep bep modified the milestones: v0.90, v0.91.0 Dec 8, 2021
@bep
Copy link
Member Author

bep commented Dec 19, 2021

Never mind, I'm not sure this is a great idea ...

@bep bep closed this as completed Dec 19, 2021
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants