github.com/weaviate/weaviate@v1.24.6/test/helper/test_data.go (about) 1 // _ _ 2 // __ _____ __ ___ ___ __ _| |_ ___ 3 // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \ 4 // \ V V / __/ (_| |\ V /| | (_| | || __/ 5 // \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___| 6 // 7 // Copyright © 2016 - 2024 Weaviate B.V. All rights reserved. 8 // 9 // CONTACT: hello@weaviate.io 10 // 11 12 package helper 13 14 import ( 15 "math/rand" 16 "time" 17 ) 18 19 // GetRandomString returns a string comprised of random 20 // samplings of charset, of length specified by caller 21 func GetRandomString(length int) string { 22 const charset = "abcdefghijklmnopqrstuvwxyz" + 23 "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*" 24 25 seededRand := rand.New(rand.NewSource(time.Now().UnixNano())) 26 27 s := make([]byte, length) 28 for n := range s { 29 s[n] = charset[seededRand.Intn(len(charset))] 30 } 31 32 return string(s) 33 }