Skip to content

Remove random.Seed() call from robot-name's approach file#2853

Merged
IsaacG merged 1 commit intoexercism:mainfrom
HerrSubset:patch-1
Feb 24, 2026
Merged

Remove random.Seed() call from robot-name's approach file#2853
IsaacG merged 1 commit intoexercism:mainfrom
HerrSubset:patch-1

Conversation

@HerrSubset
Copy link
Copy Markdown
Contributor

From the Go documentation on random.Seed():

Deprecated: As of Go 1.20 there is no reason to call Seed with a random value. Programs that call Seed with a known value to get a specific sequence of results should use New(NewSource(seed)) to obtain a local random generator.

@HerrSubset
Copy link
Copy Markdown
Contributor Author

Just created a forum post for this issue as well.

@siebenschlaefer
Copy link
Copy Markdown
Contributor

I'm not involved in the Go track in any way, but I just noticed:
You might want to make that same change in .approaches/shuffle/content.md, too, to keep the files in sync.

From the Go documentation on random.Seed():

Deprecated: As of Go 1.20 there is no reason to call Seed with a random value.
Programs that call Seed with a known value to get a specific sequence of results
should use New(NewSource(seed)) to obtain a local random generator.

The time import could then also be removed, because it was only used
when setting the seed.
@HerrSubset
Copy link
Copy Markdown
Contributor Author

Thanks for checking that @siebenschlaefer, I updated the PR.

I also tested both examples and saw that the time import was no longer needed, so removed that too from both files. Both examples now compile and pass the tests!

Copy link
Copy Markdown
Member

@SleeplessByte SleeplessByte left a comment

Choose a reason for hiding this comment

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

Looks good. The sample solution didn't seed a random number generator.

Can you confirm these approaches actually pass the tests if ran? If yes, I don't see a reason why this cannot be merged...

@SleeplessByte
Copy link
Copy Markdown
Member

cc @exercism/go

@HerrSubset
Copy link
Copy Markdown
Contributor Author

Can you confirm these approaches actually pass the tests if ran? If yes, I don't see a reason why this cannot be merged...

Yes, tested that last week after siebenschlaefer's comment :)

@IsaacG IsaacG merged commit 3ef7fc7 into exercism:main Feb 24, 2026
12 checks passed
IsaacG pushed a commit to IsaacG/fork-exercism-go that referenced this pull request Feb 24, 2026
…2853)

From the Go documentation on random.Seed():

Deprecated: As of Go 1.20 there is no reason to call Seed with a random value.
Programs that call Seed with a known value to get a specific sequence of results
should use New(NewSource(seed)) to obtain a local random generator.

The time import could then also be removed, because it was only used
when setting the seed.

---

[Forum topic](https://forum.exercism.org/t/remove-random-seed-call-from-robot-names-approach-file/16824)
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.

4 participants