增加scanf时的默认值

This commit is contained in:
tsosunchia
2023-03-02 22:12:34 +08:00
parent 362317e95e
commit a95a741ce2
3 changed files with 4 additions and 4 deletions

View File

@@ -107,7 +107,7 @@ func FastTestv6(tm bool, outEnable bool) {
fmt.Print("请选择选项:")
_, err := fmt.Scanln(&c)
if err != nil {
return
c = "1"
}
ft := FastTracer{}

View File

@@ -121,7 +121,7 @@ func FastTest(tm bool, outEnable bool) {
fmt.Print("请选择选项:")
_, err := fmt.Scanln(&c)
if err != nil {
return
c = "1"
}
if c == "2" {
FastTestv6(tm, outEnable)
@@ -132,7 +132,7 @@ func FastTest(tm bool, outEnable bool) {
fmt.Print("请选择选项:")
_, err = fmt.Scanln(&c)
if err != nil {
return
c = "1"
}
ft := FastTracer{}

View File

@@ -110,7 +110,7 @@ func DomainLookUp(host string, ipv4Only bool, dotServer string) net.IP {
fmt.Printf("Your Option: ")
_, err := fmt.Scanln(&index)
if err != nil {
return nil
index = 0
}
if index >= len(ips) || index < 0 {
fmt.Println("Your Option is invalid")