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.
This commit is contained in:
Dave Collins 2016-11-02 17:59:31 -05:00
parent 82cba61bad
commit aa53c14a19
No known key found for this signature in database
GPG Key ID: B8904D9D9C93D1F2
2 changed files with 4 additions and 1 deletions

View File

@ -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}

View File

@ -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