Every line of 'golang random' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Go code is secure.
3 func random2(y int) int { 4 x := 6 //@diag("x", "x declared but not used") 5 return y 6 }
8 func Random2(y int) int { //@Random2,mark(RandomParamY, "y") 9 return y //@godef("y", RandomParamY) 10 }
65 func (w Password) Random(s int) (string, error) { 66 b, err := w.RandomByte(s) 67 return base64.URLEncoding.EncodeToString(b), err 68 }
178 func (s *SnapContext) random(arr TallySlice, seed int64) { 179 if len(arr) <= 0 { 180 return 181 } 182 rand.Seed(seed) 183 for i := len(arr) - 1; i >= 0; i-- { 184 num := rand.Intn(len(arr)) 185 arr[i], arr[num] = arr[num], arr[i] 186 } 187 return 188 }
118 func Random() byte { 119 rand.Seed(time.Now().UnixNano()) 120 return byte(rand.Intn(256)) 121 }
577 func (m *MonotonicEntropy) random() (inc uint64, err error) { 578 if m.inc <= 1 { 579 return 1, nil 580 } 581 582 // Fast path for using a underlying rand.Rand directly. 583 if m.rng != nil { 584 // Range: [1, m.inc) 585 return 1 + uint64(m.rng.Int63n(int64(m.inc))), nil 586 } 587 588 // bitLen is the maximum bit length needed to encode a value < m.inc. 589 bitLen := bits.Len64(m.inc) 590 591 // byteLen is the maximum byte length needed to encode a value < m.inc. 592 byteLen := uint(bitLen+7) / 8 593 594 // msbitLen is the number of bits in the most significant byte of m.inc-1. 595 msbitLen := uint(bitLen % 8) 596 if msbitLen == 0 { 597 msbitLen = 8 598 } 599 600 for inc == 0 || inc >= m.inc { 601 if _, err = io.ReadFull(m.Reader, m.rand[:byteLen]); err != nil { 602 return 0, err 603 } 604 605 // Clear bits in the first byte to increase the probability 606 // that the candidate is < m.inc. 607 m.rand[0] &= uint8(int(1<
35 func (p Palette) Random() color.NRGBA { 36 return p[rand.Intn(p.Len())] 37 }
558 func (ss Strings) Random(source rand.Source) string { 559 n := len(ss) 560 561 // Avoid the extra allocation. 562 if n < 1 { 563 return "" 564 } 565 if n < 2 { 566 return ss[0] 567 } 568 rnd := rand.New(source) 569 i := rnd.Intn(n) 570 return ss[i] 571 }
238 func randuint64(rnd random.Interface) uint64 { 239 return uint64(rnd.Int63())>>31 | uint64(rnd.Int63())<<32 240 }
10 func Random() abi.File { 11 return Reader(rand.Reader, "random") 12 }