fix `-p=0` don't print result bug

This commit is contained in:
mz 2021-11-14 12:47:57 +08:00
parent 2c46cfcd0f
commit 272eb40d5b
2 changed files with 10 additions and 0 deletions

View File

@ -119,6 +119,9 @@ func main() {
}
func endPrint() {
if utils.NoPrintResult() {
return
}
if runtime.GOOS == "windows" { // 如果是 Windows 系统,则需要按下 回车键 或 Ctrl+C 退出(避免通过双击运行时,测速完毕后直接关闭)
fmt.Println("\n按下 回车键 或 Ctrl+C 退出。")
var pause int

View File

@ -23,6 +23,10 @@ var (
PrintNum = 10
)
func NoPrintResult() bool {
return PrintNum == 0
}
type PingData struct {
IP *net.IPAddr
Sended int
@ -132,6 +136,9 @@ func (s DownloadSpeedSet) Swap(i, j int) {
}
func (s DownloadSpeedSet) Print(ipv6 bool) {
if NoPrintResult() {
return
}
if len(s) <= 0 { // IP数组长度(IP数量) 大于 0 时继续
fmt.Println("\n[信息] 完整测速结果 IP 数量为 0跳过输出结果。")
return