fix lint failures with 1.31 (#5489)

This commit is contained in:
Marko
2020-10-13 10:22:53 +02:00
committed by Erik Grinaker
parent 51b8d3a153
commit 9379bc92fd
58 changed files with 98 additions and 144 deletions

View File

@@ -25,7 +25,7 @@ func (bz HexBytes) MarshalJSON() ([]byte, error) {
s := strings.ToUpper(hex.EncodeToString(bz))
jbz := make([]byte, len(s)+2)
jbz[0] = '"'
copy(jbz[1:], []byte(s))
copy(jbz[1:], s)
jbz[len(jbz)-1] = '"'
return jbz, nil
}

View File

@@ -33,21 +33,21 @@ func TestSmall(t *testing.T) {
t.Error("Expected len 3, got ", l.Len())
}
//fmt.Printf("%p %v\n", el1, el1)
//fmt.Printf("%p %v\n", el2, el2)
//fmt.Printf("%p %v\n", el3, el3)
// fmt.Printf("%p %v\n", el1, el1)
// fmt.Printf("%p %v\n", el2, el2)
// fmt.Printf("%p %v\n", el3, el3)
r1 := l.Remove(el1)
//fmt.Printf("%p %v\n", el1, el1)
//fmt.Printf("%p %v\n", el2, el2)
//fmt.Printf("%p %v\n", el3, el3)
// fmt.Printf("%p %v\n", el1, el1)
// fmt.Printf("%p %v\n", el2, el2)
// fmt.Printf("%p %v\n", el3, el3)
r2 := l.Remove(el2)
//fmt.Printf("%p %v\n", el1, el1)
//fmt.Printf("%p %v\n", el2, el2)
//fmt.Printf("%p %v\n", el3, el3)
// fmt.Printf("%p %v\n", el1, el1)
// fmt.Printf("%p %v\n", el2, el2)
// fmt.Printf("%p %v\n", el3, el3)
r3 := l.Remove(el3)
@@ -97,10 +97,10 @@ func _TestGCFifo(t *testing.T) {
for el := l.Front(); el != nil; {
l.Remove(el)
//oldEl := el
// oldEl := el
el = el.Next()
//oldEl.DetachPrev()
//oldEl.DetachNext()
// oldEl.DetachPrev()
// oldEl.DetachNext()
}
runtime.GC()
@@ -211,7 +211,7 @@ func TestScanRightDeleteRandom(t *testing.T) {
// Remove it
l.Remove(rmEl)
//fmt.Print(".")
// fmt.Print(".")
// Insert a new element
newEl := l.PushBack(-1*i - 1)

View File

@@ -22,7 +22,7 @@ func TestIterateKeysWithValues(t *testing.T) {
// Iterating Keys, checking for matching Value
for _, key := range cmap.Keys() {
val := strings.Replace(key, "key", "value", -1)
val := strings.ReplaceAll(key, "key", "value")
assert.Equal(t, val, cmap.Get(key))
}

View File

@@ -23,7 +23,7 @@ func envSet() int {
}
// Fail when FAIL_TEST_INDEX == callIndex
var callIndex int //indexes Fail calls
var callIndex int // indexes Fail calls
func Fail() {
callIndexToFail := envSet()

View File

@@ -22,16 +22,16 @@ func TestTracingLogger(t *testing.T) {
err2 := errors.New("it does not matter how slowly you go, so long as you do not stop")
logger1.With("err1", err1).Info("foo", "err2", err2)
want := strings.Replace(
strings.Replace(
want := strings.ReplaceAll(
strings.ReplaceAll(
`{"_msg":"foo","err1":"`+
fmt.Sprintf("%+v", err1)+
`","err2":"`+
fmt.Sprintf("%+v", err2)+
`","level":"info"}`,
"\t", "", -1,
), "\n", "", -1)
have := strings.Replace(strings.Replace(strings.TrimSpace(buf.String()), "\\n", "", -1), "\\t", "", -1)
"\t", "",
), "\n", "")
have := strings.ReplaceAll(strings.ReplaceAll(strings.TrimSpace(buf.String()), "\\n", ""), "\\t", "")
if want != have {
t.Errorf("\nwant '%s'\nhave '%s'", want, have)
}

View File

@@ -25,7 +25,7 @@ func (fr Fraction) String() string {
// to the equivalent fraction else returns an error. The format of the string must be
// one number followed by a slash (/) and then the other number.
func ParseFraction(f string) (Fraction, error) {
o := strings.SplitN(f, "/", -1)
o := strings.Split(f, "/")
if len(o) != 2 {
return Fraction{}, errors.New("incorrect formating: should be like \"1/3\"")
}

View File

@@ -50,11 +50,11 @@ func iotest(writer protoio.WriteCloser, reader protoio.ReadCloser) error {
r := rand.New(rand.NewSource(time.Now().UnixNano()))
for i := range msgs {
msgs[i] = test.NewPopulatedNinOptNative(r, true)
//issue 31
// issue 31
if i == 5 {
msgs[i] = &test.NinOptNative{}
}
//issue 31
// issue 31
if i == 999 {
msgs[i] = &test.NinOptNative{}
}
@@ -133,7 +133,7 @@ func TestVarintNoClose(t *testing.T) {
}
}
//issue 32
// issue 32
func TestVarintMaxSize(t *testing.T) {
buf := newBuffer()
writer := protoio.NewDelimitedWriter(buf)

View File

@@ -488,9 +488,7 @@ func benchmarkNClientsOneQuery(n int, b *testing.B) {
}
}
///////////////////////////////////////////////////////////////////////////////
/// HELPERS
///////////////////////////////////////////////////////////////////////////////
// HELPERS
func assertReceive(t *testing.T, expected interface{}, ch <-chan pubsub.Message, msgAndArgs ...interface{}) {
select {