Replace if/else by switch

This commit is contained in:
Edznux 2018-10-28 18:01:55 +01:00
commit 25a2f48a02
3 changed files with 22 additions and 17 deletions

View file

@ -119,14 +119,14 @@ func (d *Discovery) Show(by string, expr string) (err error) {
} else {
targets = d.Session.Lan.List()
}
if by == "seen" {
switch by {
case "seen":
sort.Sort(BySeenSorter(targets))
} else if by == "sent" {
case "sent":
sort.Sort(BySentSorter(targets))
} else if by == "rcvd" {
case "rcvd":
sort.Sort(ByRcvdSorter(targets))
} else {
default:
sort.Sort(ByAddressSorter(targets))
}

View file

@ -123,14 +123,14 @@ func (w *WiFiModule) Show(by string) error {
} else {
stations = w.Session.WiFi.Stations()
}
if by == "seen" {
switch by {
case "seen":
sort.Sort(ByWiFiSeenSorter(stations))
} else if by == "essid" {
case "essid":
sort.Sort(ByEssidSorter(stations))
} else if by == "channel" {
case "channel":
sort.Sort(ByChannelSorter(stations))
} else {
default:
sort.Sort(ByRSSISorter(stations))
}