Address easy golint comments

This commit is contained in:
Justin Li 2014-08-01 16:16:38 -04:00
parent a55219963b
commit d610b4ebb0
4 changed files with 13 additions and 13 deletions

View file

@ -56,13 +56,13 @@ func TestTorrentPurging(t *testing.T) {
} }
defer srv.Close() defer srv.Close()
torrentApiPath := srv.URL + "/torrents/" + url.QueryEscape(infoHash) torrentAPIPath := srv.URL + "/torrents/" + url.QueryEscape(infoHash)
// Add one seeder. // Add one seeder.
peer := makePeerParams("peer1", true) peer := makePeerParams("peer1", true)
announce(peer, srv) announce(peer, srv)
_, status, err := fetchPath(torrentApiPath) _, status, err := fetchPath(torrentAPIPath)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} else if status != http.StatusOK { } else if status != http.StatusOK {
@ -74,7 +74,7 @@ func TestTorrentPurging(t *testing.T) {
peer["event"] = "stopped" peer["event"] = "stopped"
announce(peer, srv) announce(peer, srv)
_, status, err = fetchPath(torrentApiPath) _, status, err = fetchPath(torrentAPIPath)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} else if status != http.StatusNotFound { } else if status != http.StatusNotFound {
@ -92,13 +92,13 @@ func TestStalePeerPurging(t *testing.T) {
} }
defer srv.Close() defer srv.Close()
torrentApiPath := srv.URL + "/torrents/" + url.QueryEscape(infoHash) torrentAPIPath := srv.URL + "/torrents/" + url.QueryEscape(infoHash)
// Add one seeder. // Add one seeder.
peer1 := makePeerParams("peer1", true) peer1 := makePeerParams("peer1", true)
announce(peer1, srv) announce(peer1, srv)
_, status, err := fetchPath(torrentApiPath) _, status, err := fetchPath(torrentAPIPath)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} else if status != http.StatusOK { } else if status != http.StatusOK {
@ -114,7 +114,7 @@ func TestStalePeerPurging(t *testing.T) {
// Let them both expire. // Let them both expire.
time.Sleep(30 * time.Millisecond) time.Sleep(30 * time.Millisecond)
_, status, err = fetchPath(torrentApiPath) _, status, err = fetchPath(torrentAPIPath)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} else if status != http.StatusNotFound { } else if status != http.StatusNotFound {

View file

@ -29,13 +29,13 @@ type BasicMemStats struct {
PauseTotalNs uint64 PauseTotalNs uint64
} }
type MemStatsPlaceholder interface{} type memStatsPlaceholder interface{}
// MemStatsWrapper wraps runtime.MemStats with an optionally less verbose JSON // MemStatsWrapper wraps runtime.MemStats with an optionally less verbose JSON
// representation. The JSON field names correspond exactly to the runtime field // representation. The JSON field names correspond exactly to the runtime field
// names to avoid reimplementing the entire struct. // names to avoid reimplementing the entire struct.
type MemStatsWrapper struct { type MemStatsWrapper struct {
MemStatsPlaceholder `json:"Memory"` memStatsPlaceholder `json:"Memory"`
basic *BasicMemStats basic *BasicMemStats
cache *runtime.MemStats cache *runtime.MemStats
@ -45,10 +45,10 @@ func NewMemStatsWrapper(verbose bool) *MemStatsWrapper {
stats := &MemStatsWrapper{cache: &runtime.MemStats{}} stats := &MemStatsWrapper{cache: &runtime.MemStats{}}
if verbose { if verbose {
stats.MemStatsPlaceholder = stats.cache stats.memStatsPlaceholder = stats.cache
} else { } else {
stats.basic = &BasicMemStats{} stats.basic = &BasicMemStats{}
stats.MemStatsPlaceholder = stats.basic stats.memStatsPlaceholder = stats.basic
} }
return stats return stats
} }

View file

@ -210,7 +210,7 @@ func (c *Conn) PurgeInactivePeers(purgeEmptyTorrents bool, before time.Time) err
index := 0 index := 0
keys := make([]string, len(c.torrents)) keys := make([]string, len(c.torrents))
for infohash, _ := range c.torrents { for infohash := range c.torrents {
keys[index] = infohash keys[index] = infohash
index++ index++
} }

View file

@ -61,9 +61,9 @@ type PeerKey string
func NewPeerKey(peerID string, ipv6 bool) PeerKey { func NewPeerKey(peerID string, ipv6 bool) PeerKey {
if ipv6 { if ipv6 {
return PeerKey("6:" + peerID) return PeerKey("6:" + peerID)
} else {
return PeerKey("4:" + peerID)
} }
return PeerKey("4:" + peerID)
} }
// PeerMap is a map from PeerKeys to Peers. // PeerMap is a map from PeerKeys to Peers.