package main

import (
    "fmt"
    "os"
    "strconv"
    "crypto/rand"
    "math/big"
    "unicode"
    "unsafe"
)

func main() {
    num, err := strconv.ParseUint(os.Args[1],10,64)
    if err != nil {
        panic(err)
    }
    randrunes := make([]rune,num,num)
    var char rune
    for i := 0; uint64(i) < num; i++ {
        nBig, err := rand.Int(rand.Reader, 
big.NewInt(int64(unsafe.Sizeof(char))))
        if err != nil {
            panic(err)
        }
        char = rune(nBig.Int64())
        if unicode.IsGraphic(char) {
            randrunes[i] = char
        } else {
            if i == 0 {
                continue
            }
            i--
        }
    }
    fmt.Printf("%s\n",string(randrunes))
}

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to