parent
00543ca6f7
commit
cc804d764b
@ -32,7 +32,7 @@ func main() {
|
|||||||
// produce the same sequence of numbers each time by default.
|
// produce the same sequence of numbers each time by default.
|
||||||
// To produce varying sequences, give it a seed that changes.
|
// To produce varying sequences, give it a seed that changes.
|
||||||
// Note that this is not safe to use for random numbers you
|
// Note that this is not safe to use for random numbers you
|
||||||
// intend to be secret, use `crypto/rand` for those.
|
// intend to be secret; use `crypto/rand` for those.
|
||||||
s1 := rand.NewSource(time.Now().UnixNano())
|
s1 := rand.NewSource(time.Now().UnixNano())
|
||||||
r1 := rand.New(s1)
|
r1 := rand.New(s1)
|
||||||
|
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
f0f88939692a32975d902c94066537a6ba5ab96f
|
ea6a386e4e5602247b2203fa433d4419ff5a9489
|
||||||
RaoKyUd9tgC
|
Enb5uJEx0Bt
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
# Depending on where you run this sample, some of the
|
||||||
|
# generated numbers may be different. Note that on
|
||||||
|
# the Go playground seeding with `time.Now()` still
|
||||||
|
# produces deterministic results due to the way the
|
||||||
|
# playground is implemented.
|
||||||
$ go run random-numbers.go
|
$ go run random-numbers.go
|
||||||
81,87
|
81,87
|
||||||
0.6645600532184904
|
0.6645600532184904
|
||||||
|
12
public/random-numbers
generated
12
public/random-numbers
generated
@ -43,7 +43,7 @@ generation.</p>
|
|||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td class="code leading">
|
<td class="code leading">
|
||||||
<a href="https://go.dev/play/p/RaoKyUd9tgC"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
<a href="https://go.dev/play/p/Enb5uJEx0Bt"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||||
</pre>
|
</pre>
|
||||||
</td>
|
</td>
|
||||||
@ -127,7 +127,7 @@ other ranges, for example <code>5.0 <= f' < 10.0</code>.</p>
|
|||||||
produce the same sequence of numbers each time by default.
|
produce the same sequence of numbers each time by default.
|
||||||
To produce varying sequences, give it a seed that changes.
|
To produce varying sequences, give it a seed that changes.
|
||||||
Note that this is not safe to use for random numbers you
|
Note that this is not safe to use for random numbers you
|
||||||
intend to be secret, use <code>crypto/rand</code> for those.</p>
|
intend to be secret; use <code>crypto/rand</code> for those.</p>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td class="code leading">
|
<td class="code leading">
|
||||||
@ -184,11 +184,17 @@ produces the same sequence of random numbers.</p>
|
|||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="docs">
|
<td class="docs">
|
||||||
|
<p>Depending on where you run this sample, some of the
|
||||||
|
generated numbers may be different. Note that on
|
||||||
|
the Go playground seeding with <code>time.Now()</code> still
|
||||||
|
produces deterministic results due to the way the
|
||||||
|
playground is implemented.</p>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td class="code leading">
|
<td class="code leading">
|
||||||
|
|
||||||
<pre class="chroma"><span class="gp">$</span> go run random-numbers.go
|
<pre class="chroma">
|
||||||
|
<span class="gp">$</span> go run random-numbers.go
|
||||||
<span class="go">81,87
|
<span class="go">81,87
|
||||||
</span><span class="go">0.6645600532184904
|
</span><span class="go">0.6645600532184904
|
||||||
</span><span class="go">7.123187485356329,8.434115364335547
|
</span><span class="go">7.123187485356329,8.434115364335547
|
||||||
|
Loading…
x
Reference in New Issue
Block a user