lint: golint issue fixes (#4258)

* lint: golint issue fixes

- on my local machine golint is a lot stricter than the bot so slowly going through and fixing things.

Signed-off-by: Marko Baricevic <marbar3778@yahoo.com>

* more fixes from golint

* remove isPeerPersistentFn

* add changelog entry
This commit is contained in:
Marko
2019-12-17 13:02:45 +01:00
committed by GitHub
parent f0777277ad
commit 9bd0f9e634
56 changed files with 246 additions and 246 deletions

View File

@@ -57,83 +57,83 @@ func Seed(seed int64) {
grand.Seed(seed)
}
func RandStr(length int) string {
func Str(length int) string {
return grand.Str(length)
}
func RandUint16() uint16 {
func Uint16() uint16 {
return grand.Uint16()
}
func RandUint32() uint32 {
func Uint32() uint32 {
return grand.Uint32()
}
func RandUint64() uint64 {
func Uint64() uint64 {
return grand.Uint64()
}
func RandUint() uint {
func Uint() uint {
return grand.Uint()
}
func RandInt16() int16 {
func Int16() int16 {
return grand.Int16()
}
func RandInt32() int32 {
func Int32() int32 {
return grand.Int32()
}
func RandInt64() int64 {
func Int64() int64 {
return grand.Int64()
}
func RandInt() int {
func Int() int {
return grand.Int()
}
func RandInt31() int32 {
func Int31() int32 {
return grand.Int31()
}
func RandInt31n(n int32) int32 {
func Int31n(n int32) int32 {
return grand.Int31n(n)
}
func RandInt63() int64 {
func Int63() int64 {
return grand.Int63()
}
func RandInt63n(n int64) int64 {
func Int63n(n int64) int64 {
return grand.Int63n(n)
}
func RandBool() bool {
func Bool() bool {
return grand.Bool()
}
func RandFloat32() float32 {
func Float32() float32 {
return grand.Float32()
}
func RandFloat64() float64 {
func Float64() float64 {
return grand.Float64()
}
func RandTime() time.Time {
func Time() time.Time {
return grand.Time()
}
func RandBytes(n int) []byte {
func Bytes(n int) []byte {
return grand.Bytes(n)
}
func RandIntn(n int) int {
func Intn(n int) int {
return grand.Intn(n)
}
func RandPerm(n int) []int {
func Perm(n int) []int {
return grand.Perm(n)
}

View File

@@ -14,20 +14,20 @@ import (
func TestRandStr(t *testing.T) {
l := 243
s := RandStr(l)
s := Str(l)
assert.Equal(t, l, len(s))
}
func TestRandBytes(t *testing.T) {
l := 243
b := RandBytes(l)
b := Bytes(l)
assert.Equal(t, l, len(b))
}
func TestRandIntn(t *testing.T) {
n := 243
for i := 0; i < 100; i++ {
x := RandIntn(n)
x := Intn(n)
assert.True(t, x < n)
}
}
@@ -59,18 +59,18 @@ func testThemAll() string {
// Use it.
out := new(bytes.Buffer)
perm := RandPerm(10)
perm := Perm(10)
blob, _ := json.Marshal(perm)
fmt.Fprintf(out, "perm: %s\n", blob)
fmt.Fprintf(out, "randInt: %d\n", RandInt())
fmt.Fprintf(out, "randUint: %d\n", RandUint())
fmt.Fprintf(out, "randIntn: %d\n", RandIntn(97))
fmt.Fprintf(out, "randInt31: %d\n", RandInt31())
fmt.Fprintf(out, "randInt32: %d\n", RandInt32())
fmt.Fprintf(out, "randInt63: %d\n", RandInt63())
fmt.Fprintf(out, "randInt64: %d\n", RandInt64())
fmt.Fprintf(out, "randUint32: %d\n", RandUint32())
fmt.Fprintf(out, "randUint64: %d\n", RandUint64())
fmt.Fprintf(out, "randInt: %d\n", Int())
fmt.Fprintf(out, "randUint: %d\n", Uint())
fmt.Fprintf(out, "randIntn: %d\n", Intn(97))
fmt.Fprintf(out, "randInt31: %d\n", Int31())
fmt.Fprintf(out, "randInt32: %d\n", Int32())
fmt.Fprintf(out, "randInt63: %d\n", Int63())
fmt.Fprintf(out, "randInt64: %d\n", Int64())
fmt.Fprintf(out, "randUint32: %d\n", Uint32())
fmt.Fprintf(out, "randUint64: %d\n", Uint64())
return out.String()
}
@@ -81,9 +81,9 @@ func TestRngConcurrencySafety(t *testing.T) {
go func() {
defer wg.Done()
_ = RandUint64()
<-time.After(time.Millisecond * time.Duration(RandIntn(100)))
_ = RandPerm(3)
_ = Uint64()
<-time.After(time.Millisecond * time.Duration(Intn(100)))
_ = Perm(3)
}()
}
wg.Wait()
@@ -110,7 +110,7 @@ func BenchmarkRandBytes1MiB(b *testing.B) {
func benchmarkRandBytes(b *testing.B, n int) {
for i := 0; i < b.N; i++ {
_ = RandBytes(n)
_ = Bytes(n)
}
b.ReportAllocs()
}