Skip to content

Commit

Permalink
v0.0.2 - 修复一些可能的BUG
Browse files Browse the repository at this point in the history
  • Loading branch information
spiritLHLS committed Jun 29, 2024
1 parent 12fe306 commit d451dfd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
12 changes: 7 additions & 5 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func main() {
flag.BoolVar(&showHead, "s", true, "Show head")
flag.StringVar(&language, "l", "zh", "Language parameter (options: en, zh)")
flag.StringVar(&platform, "pf", "net", "Platform parameter (options: net, cn)")
flag.StringVar(&operator, "opt", "", "Operator parameter (options: cmcc, cu, ct, sg, tw, jp, hk, global)")
flag.StringVar(&operator, "opt", "global", "Operator parameter (options: cmcc, cu, ct, sg, tw, jp, hk, global)")
flag.IntVar(&num, "num", -1, "Number of test servers, default -1 not to limit")
flag.Parse()
if showVersion {
Expand All @@ -38,7 +38,7 @@ func main() {
return
}
var url, parseType string
if strings.ToLower(platform) == "net" {
if strings.ToLower(platform) == "cn" {
if strings.ToLower(operator) == "cmcc" {
url = model.CnCMCC
} else if strings.ToLower(operator) == "cu" {
Expand All @@ -54,8 +54,8 @@ func main() {
} else if strings.ToLower(operator) == "sg" {
url = model.CnSG
}
parseType = "id"
} else if strings.ToLower(platform) == "cn" {
parseType = "url"
} else if strings.ToLower(platform) == "net" {
if strings.ToLower(operator) == "cmcc" {
url = model.NetCMCC
} else if strings.ToLower(operator) == "cu" {
Expand All @@ -70,8 +70,10 @@ func main() {
url = model.NetJP
} else if strings.ToLower(operator) == "sg" {
url = model.NetSG
} else if strings.ToLower(operator) == "global" {
url = model.NetGlobal
}
parseType = "url"
parseType = "id"
}
if url != "" {
sp.CustomSpeedTest(url, parseType, num)
Expand Down
3 changes: 2 additions & 1 deletion cmd/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ import "testing"
func Test(t *testing.T) {
main()
}
// /usr/local/go/bin/go test -timeout 360s -run ^Test$ github.com/oneclickvirt/speedtest/cmd

// /usr/local/go/bin/go test -timeout 360s -run ^Test$ github.com/oneclickvirt/speedtest/cmd
2 changes: 1 addition & 1 deletion sp/sp.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func CustomSpeedTest(url, byWhat string, num int) {
})
analyzer := speedtest.NewPacketLossAnalyzer(nil)
var PacketLoss string
if num == -1 && num >= len(pingList) {
if num == -1 || num >= len(pingList) {
num = len(pingList)
} else if len(pingList) == 0 {
fmt.Println("No match servers")
Expand Down

0 comments on commit d451dfd

Please sign in to comment.