mirror of
				https://github.com/v2fly/v2ray-core.git
				synced 2025-10-31 01:39:16 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			21 lines
		
	
	
		
			388 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			21 lines
		
	
	
		
			388 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Package dice contains common functions to generate random number.
 | |
| // It also initialize math/rand with the time in seconds at launch time.
 | |
| package dice
 | |
| 
 | |
| import (
 | |
| 	"math/rand"
 | |
| 	"time"
 | |
| )
 | |
| 
 | |
| // Roll returns a non-negative number between 0 (inclusive) and n (exclusive).
 | |
| func Roll(n int) int {
 | |
| 	if n == 1 {
 | |
| 		return 0
 | |
| 	}
 | |
| 	return rand.Intn(n)
 | |
| }
 | |
| 
 | |
| func init() {
 | |
| 	rand.Seed(time.Now().Unix())
 | |
| }
 | 
