---
source: https://iinventedlight.com/library/notes/go-randv2.md
title: "Go math/rand/v2: pseudo-random numbers for simulation, not security"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "BSD-3-Clause (The Go Authors); BSD-3-Clause (The Go Authors); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: The Go Authors, rand/v2 package reference; The Go Authors, rand.go source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-24
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-24
as_of: 2026-11-24
confidence: medium
untested: "Not reproduced (2026-11-24). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-systems: go-randv2"
tags: [go, rand, ChaCha8, PCG, pseudo-random]
client: Librarian
sources:
  - id: S1
    title: "rand/v2 package reference"
    publisher: The Go Authors
    url: https://pkg.go.dev/math/rand/v2
    accessed: 2026-11-24
    license: "BSD-3-Clause"
  - id: S2
    title: "rand.go source"
    publisher: The Go Authors
    url: https://go.dev/src/math/rand/v2/rand.go
    accessed: 2026-11-24
    license: "BSD-3-Clause"
---
# Go math/rand/v2: pseudo-random numbers for simulation, not security
**Answer:** The ChaCha8 source is a general-purpose source resistant to prediction.

## What the package is for

Functions such as Float64 and Int are safe for concurrent use by multiple goroutines.

This package's outputs might be easily predictable regardless of how it's seeded.

Package rand implements pseudo-random number generators suitable for tasks such as simulation.

A Source is not safe for concurrent use by multiple goroutines.

## Sources you can choose

Both types should be used by a single goroutine at a time.

Random numbers are generated by a Source, usually wrapped in a Rand.

The PCG source is faster but unfit for security-relevant purposes.

It should not be used for security-sensitive work.

See the crypto/rand package when you need numbers for security-sensitive work.

## See also

- [go-crypto-rand](https://iinventedlight.com/library/notes/go-crypto-rand/)
- [go-math-big](https://iinventedlight.com/library/notes/go-math-big/)
- [go-sync-mutex](https://iinventedlight.com/library/notes/go-sync-mutex/)

## Claims

- id: C1
  claim: The ChaCha8 source is a general-purpose source resistant to prediction.
  source: S1
  evidence: "The ChaCha8 source is a general-purpose source resistant to prediction."

- id: C2
  claim: The PCG source is faster but unfit for security-relevant purposes.
  source: S1
  evidence: "The PCG source is faster but unfit for security-relevant purposes."

- id: C3
  claim: Both types should be used by a single goroutine at a time.
  source: S1
  evidence: "Both types should be used by a single goroutine at a time"

- id: C4
  claim: A Source is not safe for concurrent use by multiple goroutines.
  source: S2
  evidence: "A Source is not safe for concurrent use by multiple goroutines"

## Sources

- [S1] rand/v2 package reference. The Go Authors. https://pkg.go.dev/math/rand/v2 . License: BSD-3-Clause. Accessed 2026-11-24.

- [S2] rand.go source. The Go Authors. https://go.dev/src/math/rand/v2/rand.go . License: BSD-3-Clause. Accessed 2026-11-24.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: The Go Authors, rand/v2 package reference; The Go Authors, rand.go source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
