github.com/canhui/fabric_ca2_2@v2.0.0-alpha+incompatible/integration/runner/namer.go (about) 1 package runner 2 3 /* 4 Copyright IBM Corp. All Rights Reserved. 5 6 SPDX-License-Identifier: Apache-2.0 7 */ 8 9 import ( 10 "crypto/rand" 11 "encoding/base32" 12 "fmt" 13 "io" 14 "strings" 15 ) 16 17 // UniqueName generates a random string for a Docker containers name 18 func UniqueName() string { 19 rname := make([]byte, 16) 20 _, err := io.ReadFull(rand.Reader, rname) 21 if err != nil { 22 panic(fmt.Sprintf("Error generating random name: %s", err)) 23 } 24 name := base32.StdEncoding.WithPadding(base32.NoPadding).EncodeToString(rname) 25 return strings.ToLower(name) 26 }