Go Package rand: Difference between revisions
Jump to navigation
Jump to search
Line 15: | Line 15: | ||
"time" | "time" | ||
) | ) | ||
i := rand.New(rand.NewSource(time.Now().UnixNano())).Int() | i := rand.New(rand.NewSource(time.Now().UnixNano())).Int() | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=<tt>rand.NewSource()</tt>= | =<tt>rand.NewSource()</tt>= |
Revision as of 21:44, 2 October 2023
Internal
Overview
The package math/rand
.
rand.New()
Generating a new random integer:
import (
"math/rand"
"time"
)
i := rand.New(rand.NewSource(time.Now().UnixNano())).Int()