go-overflow-sample/main.go

29 lines
495 B
Go
Raw Normal View History

package main
import "crypto/rand"
import "math/big"
import "fmt"
import "os"
import "strconv"
func main() {
if len(os.Args) < 2 {
fmt.Println("Pass a number")
os.Exit(1)
}
number, err := strconv.Atoi(os.Args[1])
if err != nil {
fmt.Println("Could not convert argument to int64")
}
RandInt(int64(number * 100))
}
func RandInt(max int64) {
i, err := rand.Int(rand.Reader, big.NewInt(int64(max)))
if err != nil {
fmt.Println("Could not randomize")
}
fmt.Println(i.Uint64())
}