From a505b99ba37802797ad486cc3d0d811d5409de6d Mon Sep 17 00:00:00 2001 From: David Hill Date: Wed, 13 May 2020 08:44:07 -0400 Subject: [PATCH 1/3] build: replace travis-ci with github actions. test go 1.14 use golangci-lint --- .github/workflows/go.yml | 27 +++++++++++++++++++++++++++ .travis.yml | 18 ------------------ README.md | 6 +++--- btcjson/chainsvrresults.go | 2 +- goclean.sh | 18 ++++-------------- mempool/mempool_test.go | 8 ++++---- txscript/pkscript_test.go | 12 ++++++------ 7 files changed, 45 insertions(+), 46 deletions(-) create mode 100644 .github/workflows/go.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000000..f722032b16 --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,27 @@ +name: Build and Test +on: [push, pull_request] +jobs: + build: + name: Go CI + runs-on: ubuntu-latest + strategy: + matrix: + go: [1.13, 1.14] + steps: + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go }} + - name: Check out source + uses: actions/checkout@v2 + - name: Install Linters + run: "curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.26.0" + - name: Build + env: + GO111MODULE: "on" + run: go build ./... + - name: Test + env: + GO111MODULE: "on" + run: | + sh ./goclean.sh diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 5a611c3960..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ -language: go -cache: - directories: - - $GOCACHE - - $GOPATH/pkg/mod - - $GOPATH/github.com/golang - - $GOPATH/gopkg.in/alecthomas -go: - - "1.13.x" -sudo: false -install: - - export PATH=$PATH:$PWD/linux-amd64/ - - GO111MODULE=on go install . ./cmd/... - - GO111MODULE=off go get -u gopkg.in/alecthomas/gometalinter.v2 - - GO111MODULE=off gometalinter.v2 --install -script: - - export PATH=$PATH:$HOME/gopath/bin - - ./goclean.sh diff --git a/README.md b/README.md index a270fd2e97..8c9d252ad4 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ btcd ==== -[![Build Status](https://travis-ci.org/btcsuite/btcd.png?branch=master)](https://travis-ci.org/btcsuite/btcd) -[![ISC License](http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org) -[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](http://godoc.org/github.com/btcsuite/btcd) +[![Build Status](https://github.com/btcsuite/btcd/workflows/Build%20and%20Test/badge.svg)](https://github.com/btcsuite/btcd/actions) +[![ISC License](https://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org) +[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](https://godoc.org/github.com/btcsuite/btcd) btcd is an alternative full node bitcoin implementation written in Go (golang). diff --git a/btcjson/chainsvrresults.go b/btcjson/chainsvrresults.go index 8cd716d409..d076b74691 100644 --- a/btcjson/chainsvrresults.go +++ b/btcjson/chainsvrresults.go @@ -271,7 +271,7 @@ type GetBlockTemplateResult struct { type MempoolFees struct { Base float64 `json:"base"` - Modified float64 `json:"base"` + Modified float64 `json:"modified"` Ancestor float64 `json:"ancestor"` Descendant float64 `json:"descendant"` } diff --git a/goclean.sh b/goclean.sh index 6d0e0ca104..4689ab360f 100755 --- a/goclean.sh +++ b/goclean.sh @@ -6,26 +6,16 @@ # 4. gosimple (https://github.com/dominikh/go-simple) # 5. unconvert (https://github.com/mdempsky/unconvert) # -# gometalinter (github.com/alecthomas/gometalinter) is used to run each static -# checker. set -ex -# Make sure gometalinter is installed and $GOPATH/bin is in your path. -# $ go get -v github.com/alecthomas/gometalinter" -# $ gometalinter --install" -if [ ! -x "$(type -p gometalinter.v2)" ]; then - exit 1 -fi - -linter_targets=$(go list ./...) +go test -tags="rpctest" ./... # Automatic checks -test -z "$(gometalinter.v2 -j 4 --disable-all \ +golangci-lint run --deadline=10m --disable-all \ --enable=gofmt \ --enable=golint \ --enable=vet \ --enable=gosimple \ ---enable=unconvert \ ---deadline=10m $linter_targets 2>&1 | grep -v 'ALL_CAPS\|OP_' 2>&1 | tee /dev/stderr)" -GO111MODULE=on go test -tags="rpctest" $linter_targets +--enable=unconvert + diff --git a/mempool/mempool_test.go b/mempool/mempool_test.go index 84aee10ab2..6d43cfd86e 100644 --- a/mempool/mempool_test.go +++ b/mempool/mempool_test.go @@ -1418,8 +1418,8 @@ func TestAncestorsDescendants(t *testing.T) { // We'll be querying for the ancestors of E. We should expect to see all // of the transactions that it depends on. expectedAncestors := map[chainhash.Hash]struct{}{ - *a.Hash(): struct{}{}, *b.Hash(): struct{}{}, - *c.Hash(): struct{}{}, *d.Hash(): struct{}{}, + *a.Hash(): {}, *b.Hash(): {}, + *c.Hash(): {}, *d.Hash(): {}, } ancestors := ctx.harness.txPool.txAncestors(e, nil) if len(ancestors) != len(expectedAncestors) { @@ -1436,8 +1436,8 @@ func TestAncestorsDescendants(t *testing.T) { // Then, we'll query for the descendants of A. We should expect to see // all of the transactions that depend on it. expectedDescendants := map[chainhash.Hash]struct{}{ - *b.Hash(): struct{}{}, *c.Hash(): struct{}{}, - *d.Hash(): struct{}{}, *e.Hash(): struct{}{}, + *b.Hash(): {}, *c.Hash(): {}, + *d.Hash(): {}, *e.Hash(): {}, } descendants := ctx.harness.txPool.txDescendants(a, nil) if len(descendants) != len(expectedDescendants) { diff --git a/txscript/pkscript_test.go b/txscript/pkscript_test.go index 841842c268..49e2db8afa 100644 --- a/txscript/pkscript_test.go +++ b/txscript/pkscript_test.go @@ -337,9 +337,9 @@ func TestComputePkScript(t *testing.T) { name: "P2WSH witness", sigScript: nil, witness: [][]byte{ - []byte{}, + {}, // Witness script. - []byte{ + { 0x21, 0x03, 0x82, 0x62, 0xa6, 0xc6, 0xce, 0xc9, 0x3c, 0x2d, 0x3e, 0xcd, 0x6c, 0x60, 0x72, 0xef, 0xea, 0x86, @@ -367,9 +367,9 @@ func TestComputePkScript(t *testing.T) { witness: [][]byte{ // Signature is not needed to re-derive the // pkScript. - []byte{}, + {}, // Compressed pubkey. - []byte{ + { 0x03, 0x82, 0x62, 0xa6, 0xc6, 0xce, 0xc9, 0x3c, 0x2d, 0x3e, 0xcd, 0x6c, 0x60, 0x72, 0xef, 0xea, 0x86, 0xd0, @@ -398,9 +398,9 @@ func TestComputePkScript(t *testing.T) { witness: [][]byte{ // Signature is not needed to re-derive the // pkScript. - []byte{}, + {}, // Malformed compressed pubkey. - []byte{ + { 0x03, 0x82, 0x62, 0xa6, 0xc6, 0xce, 0xc9, 0x3c, 0x2d, 0x3e, 0xcd, 0x6c, 0x60, 0x72, 0xef, 0xea, 0x86, 0xd0, From bc8d63bf15e8e73e102a9ba93a75a6e1e3402cc7 Mon Sep 17 00:00:00 2001 From: David Hill Date: Wed, 13 May 2020 08:48:56 -0400 Subject: [PATCH 2/3] build: update deps --- go.mod | 15 +++++---------- go.sum | 23 ++++++++++++++++++++++- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index 606399481f..15c261cef5 100644 --- a/go.mod +++ b/go.mod @@ -1,21 +1,16 @@ module github.com/btcsuite/btcd require ( - github.com/aead/siphash v1.0.1 // indirect github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f - github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d + github.com/btcsuite/btcutil v1.0.2 github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd - github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd - github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723 // indirect + github.com/btcsuite/goleveldb v1.0.0 github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792 github.com/btcsuite/winsvc v1.0.0 - github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495 - github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89 + github.com/davecgh/go-spew v1.1.1 + github.com/jessevdk/go-flags v1.4.0 github.com/jrick/logrotate v1.0.0 - github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23 // indirect - github.com/onsi/ginkgo v1.7.0 // indirect - github.com/onsi/gomega v1.4.3 // indirect - golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44 + golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37 ) go 1.12 diff --git a/go.sum b/go.sum index dc773d4775..1ead212fc8 100644 --- a/go.sum +++ b/go.sum @@ -1,21 +1,29 @@ github.com/aead/siphash v1.0.1 h1:FwHfE/T45KPKYuuSAKyyvE+oPWcaQ+CUmFW0bPlM+kg= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= +github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f h1:bAs4lUbRJpnnkd9VhRV3jjAVU7DJVjMaK+IsvSeZvFo= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d h1:yJzD/yFppdVCf6ApMkVy8cUxV0XrxdP9rVf6D87/Mng= github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= +github.com/btcsuite/btcutil v1.0.2 h1:9iZ1Terx9fMIOtq1VrwdqfsATL9MC2l8ZrUY6YZ2uts= +github.com/btcsuite/btcutil v1.0.2/go.mod h1:j9HUFwoQRsZL3V4n+qG+CUnEGHOarIxfC3Le2Yhbcts= github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd h1:R/opQEbFEy9JGkIguV40SvRY1uliPX8ifOvi6ICsFCw= github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd h1:qdGvebPBDuYDPGi1WCPjy1tGyMpmDK8IEapSsszn7HE= github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY= +github.com/btcsuite/goleveldb v1.0.0 h1:Tvd0BfvqX9o823q1j2UZ/epQo09eJh6dTcRp79ilIN4= +github.com/btcsuite/goleveldb v1.0.0/go.mod h1:QiK9vBlgftBg6rWQIj6wFzbPfRjiykIEhBH4obrXJ/I= github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723 h1:ZA/jbKoGcVAnER6pCHPEkGdZOV7U1oLUedErBHCUMs0= github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= +github.com/btcsuite/snappy-go v1.0.0 h1:ZxaA6lo2EpxGddsA8JwWOcxlzRybb444sgmeJQMJGQE= +github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792 h1:R8vQdOQdZ9Y3SkEwmHoWBmX1DNXhXZqlTpq6s4tyJGc= github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= github.com/btcsuite/winsvc v1.0.0 h1:J9B4L7e3oqhXOcm+2IuNApwzQec85lE+QaikUcCs+dk= github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= -github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495 h1:6IyqGr3fnd0tM3YxipK27TUskaOVUjU2nG45yzwcQKY= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= @@ -24,6 +32,8 @@ github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89 h1:12K8AlpT0/6QUXSfV0yi4Q0jkbq8NDtIKFtF61AoqV0= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA= +github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jrick/logrotate v1.0.0 h1:lQ1bL/n9mBNeIXoTUoYRlK4dHuNJVofX9oWqBtPnSzI= github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23 h1:FOOIBWrEkLgmlgGfMuZT83xIwfPDxEI2OHu6xUmJMFE= @@ -31,16 +41,27 @@ github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6 github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.4.3 h1:RE1xgDvH7imwFD45h+u2SgIfERHlS2yNG4DObb5BSKU= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44 h1:9lP3x0pW80sDI6t1UMSLA4to18W7R7imwAI/sWS9S8Q= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37 h1:cg5LA/zNPRzIXIWSCxQW10Rvpy94aQh3LT/ShoCpkHw= +golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2ePZzZTUrRacwib7cNsYQ= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e h1:o3PsSEY8E4eXWkXrIP9YJALUkVZqzHJT5DOasTyn8Vs= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= From f7399e6157d38144d89517c9ca1d668e1615d9c3 Mon Sep 17 00:00:00 2001 From: David Hill Date: Wed, 13 May 2020 08:58:39 -0400 Subject: [PATCH 3/3] 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 b42b7c730d..6fed37f136 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 135ef19196..e545887f8b 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 0a45f1c01d..68b61de10b 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 19ab772ef9..d238741455 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 5de001c91e..10cd0f9a86 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 3832678aaf..2d3ab10f3e 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 4e529363dc..161d866d29 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 4689ab360f..bb0cd7b600 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 cee2407566..63ad3d841e 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 b9bb18d0f5..9a76be8d4c 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 6e3205a209..1487dde590 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 fa963d4b5d..46e3fa6613 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))