Go:math/rand
lastmod 2026-11-10created 2025-11-284 edits
math/rand는 Go 표준 라이브러리의 의사 난수 생성 패키지다. rand.Intn(), rand.Float64() 같은 패키지 수준 함수와 rand.New(rand.NewSource(seed)) 로 만드는 독립 생성기를 제공하며 암호학적 용도에는 쓸 수 없어 그런 경우 crypto/rand 를 쓴다. Go 1.20 부터 전역 생성기가 자동으로 무작위 시드되어 rand.Seed() 가 deprecated 되었고 개선된 API 는 math/rand/v2 로 제공된다.
Troubleshooting
rand.Seed has been deprecated since Go 1.20
rand.Seed has been deprecated since Go 1.20 and an alternative has been available since Go 1.0: As of Go 1.20 there is no reason to call Seed with a random value. Programs that call Seed with a known value to get a specific sequence of results should use New(NewSource(seed)) to obtain a local random generator. (SA1019)
다음과 같이 수정:
See also
이 문서를 가리키는 문서