You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
x/website: Tutorial contains stale code/advice (no need to seed rand anymore) #60627
I expect to not see that paragraph. I assumed that there was an init() function for older versions of the code but forgot to change also the paragraph that explains the code.
Or maybe I am missing something about the language, I am new to GO.
What did you see instead?
The paragraph inside the blue border of the screenshot.
changed the title [-]x/website: Paragraph with older version of the code.[/-][+]x/website: Tutorial contains stale code/advice (no need to seed rand anymore)[/+]on Jun 6, 2023
I think it would be worth adding additional context rather than completely removing. I happened to be working through this example with go1.19.5 which seems to not init() the rand function, and as such had some mild confusion when my code matched but the output did not (fixed by adding a seed the example code did not have).
Installing 1.20.5 seems to have solved the seed issue, but I think for newer users it may be nice to have this section call out the change of functionality from version X to version X and that older versions require manual init seeding.
Can anything be done about this? Every single developer who starts learning Go from the official website has had a frustrating experience right from the start for the last months, because the tutorial is broken. Every week someone creates a new issue.
I would like to echo @jexlock's sentiment. I started going through the tutorial on a Linux Mint machine, and the Go version I get from sudo apt install golang is 1.18.1. It would be helpful to at least have a note that this requires 1.20, or that users below 1.20 may need to add additional code to get the example to work. Removing any mention of init entirely just makes the subsequent un-seeded behavior even more mysterious.
Activity
[-]x/website: Paragraph with older version of the code.[/-][+]x/website: Tutorial contains stale code/advice (no need to seed rand anymore)[/+]dr2chase commentedon Jun 6, 2023
@golang/tools-team
Looks like an issue to me, too.
ohmyfolly commentedon Jun 18, 2023
I think it would be worth adding additional context rather than completely removing. I happened to be working through this example with go1.19.5 which seems to not init() the rand function, and as such had some mild confusion when my code matched but the output did not (fixed by adding a seed the example code did not have).
Installing 1.20.5 seems to have solved the seed issue, but I think for newer users it may be nice to have this section call out the change of functionality from version X to version X and that older versions require manual init seeding.
findleyr commentedon Jun 21, 2023
CC @ansaba
fzipp commentedon Aug 10, 2023
Can anything be done about this? Every single developer who starts learning Go from the official website has had a frustrating experience right from the start for the last months, because the tutorial is broken. Every week someone creates a new issue.
gopherbot commentedon Aug 10, 2023
Change https://go.dev/cl/518475 mentions this issue:
_content/doc/tutorial: remove outdated paragraph about seeding the rand packageianlancetaylor commentedon Aug 11, 2023
I think this was fixed by https://go.dev/cl/507096. Sorry for the delay.
Jaculabilis commentedon Sep 8, 2023
I would like to echo @jexlock's sentiment. I started going through the tutorial on a Linux Mint machine, and the Go version I get from
sudo apt install golangis 1.18.1. It would be helpful to at least have a note that this requires 1.20, or that users below 1.20 may need to add additional code to get the example to work. Removing any mention ofinitentirely just makes the subsequent un-seeded behavior even more mysterious.leimao commentedon Jan 18, 2024
Why there is no version control for the tutorial?
Fixes golang/go#60627.
Fixes golang/go#60627.
Fixes golang/go#60627.
gopherbot commentedon Jan 24, 2024
Change https://go.dev/cl/557795 mentions this issue:
_content/doc/tutorial: add version prerequisite