fix golint issues in core/stringx (#516)
This commit is contained in:
@@ -42,10 +42,12 @@ func (ls *lockedSource) Seed(seed int64) {
|
||||
ls.source.Seed(seed)
|
||||
}
|
||||
|
||||
// Rand returns a random string.
|
||||
func Rand() string {
|
||||
return Randn(defaultRandLen)
|
||||
}
|
||||
|
||||
// RandId returns a random id string.
|
||||
func RandId() string {
|
||||
b := make([]byte, idLen)
|
||||
_, err := crand.Read(b)
|
||||
@@ -56,6 +58,7 @@ func RandId() string {
|
||||
return fmt.Sprintf("%x%x%x%x", b[0:2], b[2:4], b[4:6], b[6:8])
|
||||
}
|
||||
|
||||
// Randn returns a random string with length n.
|
||||
func Randn(n int) string {
|
||||
b := make([]byte, n)
|
||||
// A src.Int63() generates 63 random bits, enough for letterIdxMax characters!
|
||||
@@ -74,6 +77,7 @@ func Randn(n int) string {
|
||||
return string(b)
|
||||
}
|
||||
|
||||
// Seed sets the seed to seed.
|
||||
func Seed(seed int64) {
|
||||
src.Seed(seed)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user