Go Package rand: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 6: Line 6:


=<tt>rand.New()</tt>=
=<tt>rand.New()</tt>=
Generating a new random integer:
<syntaxhighlight lang='go'>
i := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
</syntaxhighlight>
=<tt>rand.NewSource()</tt>=
=<tt>rand.NewSource()</tt>=

Revision as of 21:42, 2 October 2023

Internal

Overview

rand.New()

Generating a new random integer:

i := rand.New(rand.NewSource(time.Now().UnixNano())).Int()

rand.NewSource()