shortid.go
func ID(bits int) (string, error) {
	if math.Mod(float64(bits), 8) != 0 {
		return "", errors.New("Given bits should be a multiple of 8")
	}

	b := make([]byte, bits/8)
	if _, err := rand.Read(b); err != nil {
		return "", err
	}

	return base64.RawURLEncoding.EncodeToString(b), nil
}
func ID(bits int) (string, error) {
	if math.Mod(float64(bits), 8) != 0 {
		return "", errors.New("Given bits should be a multiple of 8")
	}

	b := make([]byte, bits/8)
	if _, err := rand.Read(b); err != nil {
		return "", err
	}

	return base64.RawURLEncoding.EncodeToString(b), nil
}
func ID ( bits int ) ( string , error ) { if math . Mod ( float64 ( bits ) , 8 ) != 0 { return " " , errors . New ( " " ) } b := make ( [ ] byte , bits / 8 ) if _ , err := rand . Read ( b ) ; err != nil { return " " , err } return base64 . RawURLEncoding . EncodeToString ( b ) , nil }
// ID generates a base64 encoded URL safe unique ID using crypto/rand.
// This is a cryptographically secure pseudorandom number presented
// as an unpadded base64 encoded string.
//
// 'bits' should be a multiple of 8.
// Lenght of generated string will be ceiling(bits * 4 / 24)
ID generates a base64 encoded URL safe unique ID using crypto / rand . This is a cryptographically secure pseudorandom number presented as an unpadded base64 encoded string . bits should be a multiple of 8 . Lenght of generated string will be ceiling ( bits * 4 / 24 )