From f7399e6157d38144d89517c9ca1d668e1615d9c3 Mon Sep 17 00:00:00 2001 From: David Hill Date: Wed, 13 May 2020 08:58:39 -0400 Subject: [PATCH] build: clean linter warnings --- blockchain/difficulty_test.go | 2 +- blockchain/indexers/addrindex_test.go | 4 ++-- btcec/pubkey_test.go | 6 +++--- btcec/signature_test.go | 3 +-- btcjson/register.go | 2 +- btcjson/register_test.go | 2 +- database/ffldb/whitebox_test.go | 4 ++-- goclean.sh | 3 --- rpcserverhelp.go | 2 +- server.go | 4 +--- txscript/opcode_test.go | 4 ++-- wire/common_test.go | 12 ++++++------ 12 files changed, 21 insertions(+), 27 deletions(-) diff --git a/blockchain/difficulty_test.go b/blockchain/difficulty_test.go index b42b7c73..6fed37f1 100644 --- a/blockchain/difficulty_test.go +++ b/blockchain/difficulty_test.go @@ -63,7 +63,7 @@ func TestCalcWork(t *testing.T) { } for x, test := range tests { - bits := uint32(test.in) + bits := test.in r := CalcWork(bits) if r.Int64() != test.out { diff --git a/blockchain/indexers/addrindex_test.go b/blockchain/indexers/addrindex_test.go index 135ef191..e545887f 100644 --- a/blockchain/indexers/addrindex_test.go +++ b/blockchain/indexers/addrindex_test.go @@ -68,7 +68,7 @@ func (b *addrIndexBucket) printLevels(addrKey [addrKeySize]byte) string { if !bytes.Equal(k[:levelOffset], addrKey[:]) { continue } - level := uint8(k[levelOffset]) + level := k[levelOffset] if level > highestLevel { highestLevel = level } @@ -105,7 +105,7 @@ func (b *addrIndexBucket) sanityCheck(addrKey [addrKeySize]byte, expectedTotal i if !bytes.Equal(k[:levelOffset], addrKey[:]) { continue } - level := uint8(k[levelOffset]) + level := k[levelOffset] if level > highestLevel { highestLevel = level } diff --git a/btcec/pubkey_test.go b/btcec/pubkey_test.go index 0a45f1c0..68b61de1 100644 --- a/btcec/pubkey_test.go +++ b/btcec/pubkey_test.go @@ -232,11 +232,11 @@ func TestPubKeys(t *testing.T) { var pkStr []byte switch test.format { case pubkeyUncompressed: - pkStr = (*PublicKey)(pk).SerializeUncompressed() + pkStr = pk.SerializeUncompressed() case pubkeyCompressed: - pkStr = (*PublicKey)(pk).SerializeCompressed() + pkStr = pk.SerializeCompressed() case pubkeyHybrid: - pkStr = (*PublicKey)(pk).SerializeHybrid() + pkStr = pk.SerializeHybrid() } if !bytes.Equal(test.key, pkStr) { t.Errorf("%s pubkey: serialized keys do not match.", diff --git a/btcec/signature_test.go b/btcec/signature_test.go index 19ab772e..d2387414 100644 --- a/btcec/signature_test.go +++ b/btcec/signature_test.go @@ -464,8 +464,7 @@ func TestSignatureSerialize(t *testing.T) { func testSignCompact(t *testing.T, tag string, curve *KoblitzCurve, data []byte, isCompressed bool) { - tmp, _ := NewPrivateKey(curve) - priv := (*PrivateKey)(tmp) + priv, _ := NewPrivateKey(curve) hashed := []byte("testing") sig, err := SignCompact(curve, priv, hashed, isCompressed) diff --git a/btcjson/register.go b/btcjson/register.go index 5de001c9..10cd0f9a 100644 --- a/btcjson/register.go +++ b/btcjson/register.go @@ -287,6 +287,6 @@ func RegisteredCmdMethods() []string { methods = append(methods, k) } - sort.Sort(sort.StringSlice(methods)) + sort.Strings(methods) return methods } diff --git a/btcjson/register_test.go b/btcjson/register_test.go index 3832678a..2d3ab10f 100644 --- a/btcjson/register_test.go +++ b/btcjson/register_test.go @@ -256,7 +256,7 @@ func TestRegisteredCmdMethods(t *testing.T) { // Ensure the returned methods are sorted. sortedMethods := make([]string, len(methods)) copy(sortedMethods, methods) - sort.Sort(sort.StringSlice(sortedMethods)) + sort.Strings(sortedMethods) if !reflect.DeepEqual(sortedMethods, methods) { t.Fatal("RegisteredCmdMethods: methods are not sorted") } diff --git a/database/ffldb/whitebox_test.go b/database/ffldb/whitebox_test.go index 4e529363..161d866d 100644 --- a/database/ffldb/whitebox_test.go +++ b/database/ffldb/whitebox_test.go @@ -643,9 +643,9 @@ func TestFailureScenarios(t *testing.T) { // context. maxSize := int64(-1) if maxFileSize, ok := tc.maxFileSizes[fileNum]; ok { - maxSize = int64(maxFileSize) + maxSize = maxFileSize } - file := &mockFile{maxSize: int64(maxSize)} + file := &mockFile{maxSize: maxSize} tc.files[fileNum] = &lockableFile{file: file} return file, nil } diff --git a/goclean.sh b/goclean.sh index 4689ab36..bb0cd7b6 100755 --- a/goclean.sh +++ b/goclean.sh @@ -1,7 +1,6 @@ #!/bin/bash # The script does automatic checking on a Go package and its sub-packages, including: # 1. gofmt (http://golang.org/cmd/gofmt/) -# 2. golint (https://github.com/golang/lint) # 3. go vet (http://golang.org/cmd/vet) # 4. gosimple (https://github.com/dominikh/go-simple) # 5. unconvert (https://github.com/mdempsky/unconvert) @@ -14,8 +13,6 @@ go test -tags="rpctest" ./... # Automatic checks golangci-lint run --deadline=10m --disable-all \ --enable=gofmt \ ---enable=golint \ --enable=vet \ --enable=gosimple \ --enable=unconvert - diff --git a/rpcserverhelp.go b/rpcserverhelp.go index cee24075..63ad3d84 100644 --- a/rpcserverhelp.go +++ b/rpcserverhelp.go @@ -818,7 +818,7 @@ func (c *helpCacher) rpcUsage(includeWebsockets bool) (string, error) { } } - sort.Sort(sort.StringSlice(usageTexts)) + sort.Strings(usageTexts) c.usage = strings.Join(usageTexts, "\n") return c.usage, nil } diff --git a/server.go b/server.go index b9bb18d0..9a76be8d 100644 --- a/server.go +++ b/server.go @@ -2270,9 +2270,7 @@ out: // When an InvVect has been added to a block, we can // now remove it, if it was present. case broadcastInventoryDel: - if _, ok := pendingInvs[*msg]; ok { - delete(pendingInvs, *msg) - } + delete(pendingInvs, *msg) } case <-timer.C: diff --git a/txscript/opcode_test.go b/txscript/opcode_test.go index 6e3205a2..1487dde5 100644 --- a/txscript/opcode_test.go +++ b/txscript/opcode_test.go @@ -124,7 +124,7 @@ func TestOpcodeDisasm(t *testing.T) { // OP_UNKNOWN#. case opcodeVal >= 0xba && opcodeVal <= 0xf9 || opcodeVal == 0xfc: - expectedStr = "OP_UNKNOWN" + strconv.Itoa(int(opcodeVal)) + expectedStr = "OP_UNKNOWN" + strconv.Itoa(opcodeVal) } pop := parsedOpcode{opcode: &opcodeArray[opcodeVal], data: data} @@ -190,7 +190,7 @@ func TestOpcodeDisasm(t *testing.T) { // OP_UNKNOWN#. case opcodeVal >= 0xba && opcodeVal <= 0xf9 || opcodeVal == 0xfc: - expectedStr = "OP_UNKNOWN" + strconv.Itoa(int(opcodeVal)) + expectedStr = "OP_UNKNOWN" + strconv.Itoa(opcodeVal) } pop := parsedOpcode{opcode: &opcodeArray[opcodeVal], data: data} diff --git a/wire/common_test.go b/wire/common_test.go index fa963d4b..46e3fa66 100644 --- a/wire/common_test.go +++ b/wire/common_test.go @@ -118,15 +118,15 @@ func TestElementWire(t *testing.T) { }, }, { - ServiceFlag(SFNodeNetwork), + SFNodeNetwork, []byte{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, }, { - InvType(InvTypeTx), + InvTypeTx, []byte{0x01, 0x00, 0x00, 0x00}, }, { - BitcoinNet(MainNet), + MainNet, []byte{0xf9, 0xbe, 0xb4, 0xd9}, }, // Type not supported by the "fast" path and requires reflection. @@ -211,9 +211,9 @@ func TestElementWireErrors(t *testing.T) { }), 0, io.ErrShortWrite, io.EOF, }, - {ServiceFlag(SFNodeNetwork), 0, io.ErrShortWrite, io.EOF}, - {InvType(InvTypeTx), 0, io.ErrShortWrite, io.EOF}, - {BitcoinNet(MainNet), 0, io.ErrShortWrite, io.EOF}, + {SFNodeNetwork, 0, io.ErrShortWrite, io.EOF}, + {InvTypeTx, 0, io.ErrShortWrite, io.EOF}, + {MainNet, 0, io.ErrShortWrite, io.EOF}, } t.Logf("Running %d tests", len(tests))