显示主菜单
()
| 27 | |
| 28 | // 显示主菜单 |
| 29 | func showMenu() { |
| 30 | scanner := bufio.NewScanner(os.Stdin) |
| 31 | for { |
| 32 | fmt.Println("----------------------------------------") |
| 33 | fmt.Println("1. IPV4 优选 (TLS)") |
| 34 | fmt.Println("2. IPV4 优选 (非 TLS)") |
| 35 | fmt.Println("3. IPV6 优选 (TLS)") |
| 36 | fmt.Println("4. IPV6 优选 (非 TLS)") |
| 37 | fmt.Println("5. 单 IP 测速 (TLS)") |
| 38 | fmt.Println("6. 单 IP 测速 (非 TLS)") |
| 39 | fmt.Println("7. 清空缓存") |
| 40 | fmt.Println("8. 更新数据") |
| 41 | fmt.Println("0. 退出") |
| 42 | fmt.Print("请选择菜单 (默认 0): ") |
| 43 | |
| 44 | if !scanner.Scan() { |
| 45 | break |
| 46 | } |
| 47 | input := strings.TrimSpace(scanner.Text()) |
| 48 | if input == "" { |
| 49 | input = "0" |
| 50 | } |
| 51 | |
| 52 | switch input { |
| 53 | case "0": |
| 54 | fmt.Println("退出成功") |
| 55 | return |
| 56 | case "1": |
| 57 | runIPSelector(4, true) |
| 58 | case "2": |
| 59 | runIPSelector(4, false) |
| 60 | case "3": |
| 61 | runIPSelector(6, true) |
| 62 | case "4": |
| 63 | runIPSelector(6, false) |
| 64 | case "5": |
| 65 | runSingleSpeedTest(true) |
| 66 | case "6": |
| 67 | runSingleSpeedTest(false) |
| 68 | case "7": |
| 69 | clearCache() |
| 70 | case "8": |
| 71 | updateData() |
| 72 | default: |
| 73 | fmt.Println("无效输入,请重新选择") |
| 74 | } |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | // runIPSelector 运行 IP 优选流程 |
| 79 | func runIPSelector(ipType int, useTLS bool) { |
no test coverage detected