-5

hello Golang devs I am learning golang and I am using the Math/Rand package. I am curious why I am getting the same result on:

// always returning 81

 rand.Intn(100)
Mohammad Quanit
  • 120
  • 2
  • 14
  • [Properly setting seed Random Number Generator](https://stackoverflow.com/questions/12321133/how-to-properly-seed-random-number-generator/12321192#12321192) – Gaurav Dhiman Jan 18 '20 at 09:39

1 Answers1

5

The documentation for math/rand says:

Top-level functions, such as Float64 and Int, use a default shared Source that produces a deterministic [fixed] sequence of values each time a program is run. Use the Seed function to initialize the default Source if different behavior is required for each run.

Peter O.
  • 32,158
  • 14
  • 82
  • 96