-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix (id): work with multiple containers
- Loading branch information
1 parent
e34c2a0
commit 2a69ffa
Showing
3 changed files
with
25 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package common | ||
|
||
import ( | ||
"crypto/rand" | ||
"math/big" | ||
) | ||
|
||
var Letters = []rune("abcdefghijklmnopqrstuvwxyz0123456789") | ||
|
||
func RandomString(n int) string { | ||
b := make([]rune, n) | ||
for i := range b { | ||
max := *big.NewInt(int64(len(Letters))) | ||
r, err := rand.Int(rand.Reader, &max) | ||
if err != nil { | ||
b[i] = Letters[0] | ||
} else { | ||
b[i] = Letters[r.Int64()] | ||
} | ||
} | ||
return string(b) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters