diff --git a/.travis.yml b/.travis.yml index ae23948..ba96150 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,10 @@ language: go go: - - 1.6.3 - - 1.7 + - 1.6.x + - 1.7.x sudo: false install: - go get -d -t -v ./... - - go get -v golang.org/x/tools/cmd/cover - go get -v github.com/alecthomas/gometalinter - gometalinter --install script: diff --git a/address_test.go b/address_test.go index 5ee2a6a..cb5539b 100644 --- a/address_test.go +++ b/address_test.go @@ -1,4 +1,4 @@ -// Copyright (c) 2013, 2014 The btcsuite developers +// Copyright (c) 2013-2017 The btcsuite developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. @@ -12,14 +12,10 @@ import ( "testing" "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcutil" "github.com/btcsuite/golangcrypto/ripemd160" ) -// invalidNet is an invalid bitcoin network. -const invalidNet = wire.BitcoinNet(0xffffffff) - func TestAddresses(t *testing.T) { tests := []struct { name string diff --git a/appdata.go b/appdata.go index 766fd10..e36cf7c 100644 --- a/appdata.go +++ b/appdata.go @@ -1,4 +1,4 @@ -// Copyright (c) 2013-2014 The btcsuite developers +// Copyright (c) 2013-2017 The btcsuite developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. @@ -24,10 +24,8 @@ func appDataDir(goos, appName string, roaming bool) string { } // The caller really shouldn't prepend the appName with a period, but - // if they do, handle it gracefully by stripping it. - if strings.HasPrefix(appName, ".") { - appName = appName[1:] - } + // if they do, handle it gracefully by trimming it. + appName = strings.TrimPrefix(appName, ".") appNameUpper := string(unicode.ToUpper(rune(appName[0]))) + appName[1:] appNameLower := string(unicode.ToLower(rune(appName[0]))) + appName[1:] diff --git a/base58/base58_test.go b/base58/base58_test.go index eb259b8..eb72d36 100644 --- a/base58/base58_test.go +++ b/base58/base58_test.go @@ -1,4 +1,4 @@ -// Copyright (c) 2013-2014 The btcsuite developers +// Copyright (c) 2013-2017 The btcsuite developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. @@ -80,7 +80,7 @@ func TestBase58(t *testing.T) { t.Errorf("hex.DecodeString failed failed #%d: got: %s", x, test.in) continue } - if res := base58.Decode(test.out); bytes.Equal(res, b) != true { + if res := base58.Decode(test.out); !bytes.Equal(res, b) { t.Errorf("Decode test #%d failed: got: %q want: %q", x, res, test.in) continue diff --git a/coinset/coins.go b/coinset/coins.go index 1d8f4a3..1777918 100644 --- a/coinset/coins.go +++ b/coinset/coins.go @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2016 The btcsuite developers +// Copyright (c) 2014-2017 The btcsuite developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. @@ -203,10 +203,8 @@ func (s MinNumberCoinSelector) CoinSelect(targetValue btcutil.Amount, coins []Co sortedCoins := make([]Coin, 0, len(coins)) sortedCoins = append(sortedCoins, coins...) sort.Sort(sort.Reverse(byAmount(sortedCoins))) - return (&MinIndexCoinSelector{ - MaxInputs: s.MaxInputs, - MinChangeAmount: s.MinChangeAmount, - }).CoinSelect(targetValue, sortedCoins) + + return MinIndexCoinSelector(s).CoinSelect(targetValue, sortedCoins) } // MaxValueAgeCoinSelector is a CoinSelector that attempts to construct @@ -227,10 +225,8 @@ func (s MaxValueAgeCoinSelector) CoinSelect(targetValue btcutil.Amount, coins [] sortedCoins := make([]Coin, 0, len(coins)) sortedCoins = append(sortedCoins, coins...) sort.Sort(sort.Reverse(byValueAge(sortedCoins))) - return (&MinIndexCoinSelector{ - MaxInputs: s.MaxInputs, - MinChangeAmount: s.MinChangeAmount, - }).CoinSelect(targetValue, sortedCoins) + + return MinIndexCoinSelector(s).CoinSelect(targetValue, sortedCoins) } // MinPriorityCoinSelector is a CoinSelector that attempts to construct diff --git a/goclean.sh b/goclean.sh index 3640862..4130848 100755 --- a/goclean.sh +++ b/goclean.sh @@ -4,9 +4,10 @@ # 2. goimports (https://github.com/bradfitz/goimports) # 3. golint (https://github.com/golang/lint) # 4. go vet (http://golang.org/cmd/vet) -# 5. unconvert (https://github.com/mdempsky/unconvert) -# 6. race detector (http://blog.golang.org/race-detector) -# 7. test coverage (http://blog.golang.org/cover) +# 5. gosimple (https://github.com/dominikh/go-simple) +# 6. unconvert (https://github.com/mdempsky/unconvert) +# 7. race detector (http://blog.golang.org/race-detector) +# 8. test coverage (http://blog.golang.org/cover) # # gometalint (github.com/alecthomas/gometalinter) is used to run each each # static checker. @@ -19,6 +20,7 @@ test -z "$(gometalinter --disable-all \ --enable=goimports \ --enable=golint \ --enable=vet \ +--enable=gosimple \ --enable=unconvert \ --deadline=120s ./... | grep -v 'ExampleNew' 2>&1 | tee /dev/stderr)" env GORACE="halt_on_error=1" go test -race ./... diff --git a/hdkeychain/extendedkey_test.go b/hdkeychain/extendedkey_test.go index 37e90e1..2bb8c17 100644 --- a/hdkeychain/extendedkey_test.go +++ b/hdkeychain/extendedkey_test.go @@ -1,4 +1,4 @@ -// Copyright (c) 2014 The btcsuite developers +// Copyright (c) 2014-2017 The btcsuite developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. @@ -897,7 +897,7 @@ func TestZero(t *testing.T) { // times. testZeroed := func(i int, testName string, key *hdkeychain.ExtendedKey) bool { // Zeroing a key should result in it no longer being private - if key.IsPrivate() != false { + if key.IsPrivate() { t.Errorf("IsPrivate #%d (%s): mismatched key type -- "+ "want private %v, got private %v", i, testName, false, key.IsPrivate())