go-overflow-sample/main.go
Georg Pfuetzenreuter bf11085207
Init
Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
2024-09-28 20:41:47 +02:00

29 lines
495 B
Go

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())
}