From aa53c14a191d8c108e9a3bc88b6cca28c25a5242 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Wed, 2 Nov 2016 17:59:31 -0500 Subject: [PATCH] addrmgr/btcd: Updates for staticcheck results. This makes two modifications based on the results of staticcheck. The first is to use a simplified zero value for the time in the addrmgr package tests. The second is check any errors when opening a directory while attempting to perform old version upgrades. --- addrmgr/knownaddress_test.go | 2 +- upgrade.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/addrmgr/knownaddress_test.go b/addrmgr/knownaddress_test.go index 05609ec9..79503df3 100644 --- a/addrmgr/knownaddress_test.go +++ b/addrmgr/knownaddress_test.go @@ -61,7 +61,7 @@ func TestIsBad(t *testing.T) { secondsOld := time.Now().Add(-2 * time.Second) minutesOld := time.Now().Add(-27 * time.Minute) hoursOld := time.Now().Add(-5 * time.Hour) - zeroTime, _ := time.Parse("Jan 1, 1970 at 0:00am (GMT)", "Jan 1, 1970 at 0:00am (GMT)") + zeroTime := time.Time{} futureNa := &wire.NetAddress{Timestamp: future} minutesOldNa := &wire.NetAddress{Timestamp: minutesOld} diff --git a/upgrade.go b/upgrade.go index 78bc6f2d..da9c27b7 100644 --- a/upgrade.go +++ b/upgrade.go @@ -13,6 +13,9 @@ import ( // dirEmpty returns whether or not the specified directory path is empty. func dirEmpty(dirPath string) (bool, error) { f, err := os.Open(dirPath) + if err != nil { + return false, err + } defer f.Close() // Read the names of a max of one entry from the directory. When the