4
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2025-06-28 16:09:23 +00:00

Update vendor

This commit is contained in:
Wim
2017-06-06 00:01:05 +02:00
parent 2eecaccd1c
commit 3a183cb218
49 changed files with 534 additions and 1421 deletions

View File

@ -2,22 +2,24 @@ package random
import (
"math/rand"
"strings"
"time"
)
type (
Random struct {
charset Charset
}
Charset string
)
// Charsets
const (
Alphanumeric Charset = Alphabetic + Numeric
Alphabetic Charset = "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Numeric Charset = "0123456789"
Hex Charset = Numeric + "abcdef"
Uppercase string = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Lowercase = "abcdefghijklmnopqrstuvwxyz"
Alphabetic = Uppercase + Lowercase
Numeric = "0123456789"
Alphanumeric = Alphabetic + Numeric
Symbols = "`" + `~!@#$%^&*()-_+={}[]|\;:"<>,./?`
Hex = Numeric + "abcdef"
)
var (
@ -26,27 +28,21 @@ var (
func New() *Random {
rand.Seed(time.Now().UnixNano())
return &Random{
charset: Alphanumeric,
return new(Random)
}
func (r *Random) String(length uint8, charsets ...string) string {
charset := strings.Join(charsets, "")
if charset == "" {
charset = Alphanumeric
}
}
func (r *Random) SetCharset(c Charset) {
r.charset = c
}
func (r *Random) String(length uint8) string {
b := make([]byte, length)
for i := range b {
b[i] = r.charset[rand.Int63()%int64(len(r.charset))]
b[i] = charset[rand.Int63()%int64(len(charset))]
}
return string(b)
}
func SetCharset(c Charset) {
global.SetCharset(c)
}
func String(length uint8) string {
return global.String(length)
func String(length uint8, charsets ...string) string {
return global.String(length, charsets...)
}