minor code cleanup
This commit is contained in:
10
main.go
10
main.go
@@ -58,9 +58,8 @@ func (m UploadManager) Upload() (float64, error) {
|
||||
return 0, err
|
||||
}
|
||||
return float64(up), nil
|
||||
} else {
|
||||
return 0, fmt.Errorf("could not parse bandwidth from tc")
|
||||
}
|
||||
return 0, fmt.Errorf("could not parse bandwidth from tc")
|
||||
}
|
||||
|
||||
func (m UploadManager) SetUpload(upload float64) (float64, error) {
|
||||
@@ -102,10 +101,9 @@ func doPing(host string, count int, interval time.Duration) (*ping.Statistics, e
|
||||
for _, addr := range addrs {
|
||||
if addr.(*net.IPNet).IP.To4() == nil {
|
||||
continue
|
||||
} else {
|
||||
pinger.Source = addr.(*net.IPNet).IP.String()
|
||||
break
|
||||
}
|
||||
pinger.Source = addr.(*net.IPNet).IP.String()
|
||||
break
|
||||
}
|
||||
|
||||
if pinger.Source == "" {
|
||||
@@ -118,7 +116,7 @@ func doPing(host string, count int, interval time.Duration) (*ping.Statistics, e
|
||||
}
|
||||
log.Debugf("[PING] %s: %s±%s %d%% loss", host, pinger.Statistics().AvgRtt, pinger.Statistics().StdDevRtt,
|
||||
int(pinger.Statistics().PacketLoss))
|
||||
if pinger.Statistics().PacketLoss == 100 {
|
||||
if pinger.Statistics().PacketLoss == 100 { //nolint:gomnd
|
||||
return nil, ErrorNoResponse
|
||||
}
|
||||
return pinger.Statistics(), nil
|
||||
|
Reference in New Issue
Block a user