mirror of
https://github.com/XIU2/CloudflareSpeedTest.git
synced 2026-03-02 11:57:05 +08:00
fix -p=0 don't print result bug
This commit is contained in:
3
main.go
3
main.go
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user