summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCalvin Morrison <calvin@pobox.com>2026-01-03 17:29:24 -0500
committerCalvin Morrison <calvin@pobox.com>2026-01-03 17:29:24 -0500
commit959e250b824043384cfe7d4274ed7f2f9949230d (patch)
tree8aeaebfb1016be71eed4fdb3f242662832f64748
parent17086b56a186eb595ccb8087a6d6d9722ac5734d (diff)
learning about go fmtHEADmaster
-rw-r--r--fsbm.go53
1 files changed, 27 insertions, 26 deletions
diff --git a/fsbm.go b/fsbm.go
index e26faf3..4b6dad2 100644
--- a/fsbm.go
+++ b/fsbm.go
@@ -1,12 +1,14 @@
package main
-import "fmt"
-import "bufio"
-import "flag"
-import "time"
-import "os"
-import "strings"
-import "strconv"
+import (
+ "bufio"
+ "flag"
+ "fmt"
+ "os"
+ "strconv"
+ "strings"
+ "time"
+)
type Iface struct {
Name string
@@ -68,17 +70,16 @@ func main() {
os.Exit(1)
}
- limitIfaces := false
- requestedIfaces := make(map[string]struct{})
- if *interfaceFlag != "" {
- for _, name := range strings.Split(*interfaceFlag, ",") {
- requestedIfaces[name] = struct{}{}
- }
- if len(requestedIfaces) > 0 {
- limitIfaces = true
- }
- }
-
+ limitIfaces := false
+ requestedIfaces := make(map[string]struct{})
+ if *interfaceFlag != "" {
+ for _, name := range strings.Split(*interfaceFlag, ",") {
+ requestedIfaces[name] = struct{}{}
+ }
+ if len(requestedIfaces) > 0 {
+ limitIfaces = true
+ }
+ }
ifaces := make(map[string]Iface)
var prevTime time.Time
@@ -101,12 +102,12 @@ func main() {
if !found {
continue
}
- if limitIfaces {
- _, ok := requestedIfaces[name];
- if !ok {
- continue
- }
- }
+ if limitIfaces {
+ _, ok := requestedIfaces[name]
+ if !ok {
+ continue
+ }
+ }
fields := strings.Fields(rest)
if len(fields) != 16 {
@@ -130,14 +131,14 @@ func main() {
timeDiff := openTime.Sub(prevTime).Seconds()
rxRate := float64(cur.RxBytes-prev.RxBytes) / timeDiff
txRate := float64(cur.TxBytes-prev.TxBytes) / timeDiff
- fmt.Printf("%s: (%s, %s) ", name, humanBps(rxRate, *rawFlag, *bitFlag), humanBps(txRate, *rawFlag, *bitFlag))
+ fmt.Printf("%s: (%s, %s) ", name, humanBps(rxRate, *rawFlag, *bitFlag), humanBps(txRate, *rawFlag, *bitFlag))
}
ifaces[name] = cur
}
- fmt.Printf("\n");
+ fmt.Printf("\n")
file.Close()
prevTime = openTime
time.Sleep(interval)