Go’s |
|
![]() ![]()
|
|
|
|
|
|
For example, |
|
|
|
This can be used to generate random floats in
other ranges, for example |
|
The default number generator is deterministic, so it’ll
produce the same sequence of numbers each time by default.
To produce varying sequences, give it a seed that changes.
Note that this is not safe to use for random numbers you
intend to be secret; use |
|
Call the resulting |
|
If you seed a source with the same number, it produces the same sequence of random numbers. |
|
Depending on where you run this sample, some of the
generated numbers may be different. Note that on
the Go playground seeding with |
|
See the |
Next example: Number Parsing.