From d610b4ebb086a93f71afe96a8aed9aabf6e12659 Mon Sep 17 00:00:00 2001 From: Justin Li Date: Fri, 1 Aug 2014 16:16:38 -0400 Subject: [PATCH] Address easy golint comments --- http/announce_test.go | 12 ++++++------ stats/mem.go | 8 ++++---- tracker/memory/conn.go | 2 +- tracker/models/models.go | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/http/announce_test.go b/http/announce_test.go index 047db3f..8b89610 100644 --- a/http/announce_test.go +++ b/http/announce_test.go @@ -56,13 +56,13 @@ func TestTorrentPurging(t *testing.T) { } defer srv.Close() - torrentApiPath := srv.URL + "/torrents/" + url.QueryEscape(infoHash) + torrentAPIPath := srv.URL + "/torrents/" + url.QueryEscape(infoHash) // Add one seeder. peer := makePeerParams("peer1", true) announce(peer, srv) - _, status, err := fetchPath(torrentApiPath) + _, status, err := fetchPath(torrentAPIPath) if err != nil { t.Fatal(err) } else if status != http.StatusOK { @@ -74,7 +74,7 @@ func TestTorrentPurging(t *testing.T) { peer["event"] = "stopped" announce(peer, srv) - _, status, err = fetchPath(torrentApiPath) + _, status, err = fetchPath(torrentAPIPath) if err != nil { t.Fatal(err) } else if status != http.StatusNotFound { @@ -92,13 +92,13 @@ func TestStalePeerPurging(t *testing.T) { } defer srv.Close() - torrentApiPath := srv.URL + "/torrents/" + url.QueryEscape(infoHash) + torrentAPIPath := srv.URL + "/torrents/" + url.QueryEscape(infoHash) // Add one seeder. peer1 := makePeerParams("peer1", true) announce(peer1, srv) - _, status, err := fetchPath(torrentApiPath) + _, status, err := fetchPath(torrentAPIPath) if err != nil { t.Fatal(err) } else if status != http.StatusOK { @@ -114,7 +114,7 @@ func TestStalePeerPurging(t *testing.T) { // Let them both expire. time.Sleep(30 * time.Millisecond) - _, status, err = fetchPath(torrentApiPath) + _, status, err = fetchPath(torrentAPIPath) if err != nil { t.Fatal(err) } else if status != http.StatusNotFound { diff --git a/stats/mem.go b/stats/mem.go index fbf0149..96db1d2 100644 --- a/stats/mem.go +++ b/stats/mem.go @@ -29,13 +29,13 @@ type BasicMemStats struct { PauseTotalNs uint64 } -type MemStatsPlaceholder interface{} +type memStatsPlaceholder interface{} // MemStatsWrapper wraps runtime.MemStats with an optionally less verbose JSON // representation. The JSON field names correspond exactly to the runtime field // names to avoid reimplementing the entire struct. type MemStatsWrapper struct { - MemStatsPlaceholder `json:"Memory"` + memStatsPlaceholder `json:"Memory"` basic *BasicMemStats cache *runtime.MemStats @@ -45,10 +45,10 @@ func NewMemStatsWrapper(verbose bool) *MemStatsWrapper { stats := &MemStatsWrapper{cache: &runtime.MemStats{}} if verbose { - stats.MemStatsPlaceholder = stats.cache + stats.memStatsPlaceholder = stats.cache } else { stats.basic = &BasicMemStats{} - stats.MemStatsPlaceholder = stats.basic + stats.memStatsPlaceholder = stats.basic } return stats } diff --git a/tracker/memory/conn.go b/tracker/memory/conn.go index 05b3797..a598782 100644 --- a/tracker/memory/conn.go +++ b/tracker/memory/conn.go @@ -210,7 +210,7 @@ func (c *Conn) PurgeInactivePeers(purgeEmptyTorrents bool, before time.Time) err index := 0 keys := make([]string, len(c.torrents)) - for infohash, _ := range c.torrents { + for infohash := range c.torrents { keys[index] = infohash index++ } diff --git a/tracker/models/models.go b/tracker/models/models.go index 5e35572..6794640 100644 --- a/tracker/models/models.go +++ b/tracker/models/models.go @@ -61,9 +61,9 @@ type PeerKey string func NewPeerKey(peerID string, ipv6 bool) PeerKey { if ipv6 { return PeerKey("6:" + peerID) - } else { - return PeerKey("4:" + peerID) } + + return PeerKey("4:" + peerID) } // PeerMap is a map from PeerKeys to Peers.