feat: show version in stats

This commit is contained in:
Shengjing Zhu
2022-07-24 21:09:07 +08:00
parent 74a362f803
commit 6962a4bdc6
4 changed files with 39 additions and 4 deletions

View File

@@ -4,6 +4,7 @@ import (
"bufio"
"bytes"
"runtime"
"runtime/debug"
"strconv"
"strings"
@@ -25,10 +26,16 @@ func stats(dev *device.Device) func() (any, error) {
SentBytes int64
NumGoroutine int
Version string
}{
NumGoroutine: runtime.NumGoroutine(),
}
info, ok := debug.ReadBuildInfo()
if ok {
stats.Version = info.Main.Version
}
scanner := bufio.NewScanner(&buf)
for scanner.Scan() {
line := scanner.Text()