From aff8448e335aae869f2ba81dd717685c10830dba Mon Sep 17 00:00:00 2001 From: spiritlhl <103393591+spiritLHLS@users.noreply.github.com> Date: Sun, 30 Jun 2024 04:16:53 +0000 Subject: [PATCH] =?UTF-8?q?v0.0.10=20-=20=E4=BC=98=E5=8C=96=E6=8B=BC?= =?UTF-8?q?=E6=8E=A5=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yaml | 2 +- cmd/main.go | 6 +++--- uts/uts.go | 24 +++++++++++++----------- uts/version.go | 2 +- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d4b7356..f2dec1f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -24,7 +24,7 @@ jobs: run: | git config --global user.name 'github-actions' git config --global user.email 'github-actions@github.com' - TAG="v0.0.9-$(date +'%Y%m%d%H%M%S')" + TAG="v0.0.10-$(date +'%Y%m%d%H%M%S')" git tag $TAG git push origin $TAG env: diff --git a/cmd/main.go b/cmd/main.go index ab8a020..a496436 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -69,14 +69,14 @@ func main() { } if uts.IPV4 { fmt.Println(Blue("IPV4:")) - uts.RunTests(client, "ipv4", language, useBar) + fmt.Printf(uts.RunTests(client, "ipv4", language, useBar)) } if uts.IPV6 { fmt.Println(Blue("IPV6:")) if mode == 6 { - uts.RunTests(client, "ipv6", language, useBar) + fmt.Printf(uts.RunTests(client, "ipv6", language, useBar)) } else { - uts.RunTests(utils.Ipv6HttpClient, "ipv6", language, useBar) + fmt.Printf(uts.RunTests(utils.Ipv6HttpClient, "ipv6", language, useBar)) } } } diff --git a/uts/uts.go b/uts/uts.go index c3dddc9..d08a16f 100644 --- a/uts/uts.go +++ b/uts/uts.go @@ -146,7 +146,7 @@ func PrintCenteredMessage(message string, totalLength int) string { return (leftPadding + message + rightPadding + "\n") } -func FormarPrint(message string) { +func FormarPrint(message string) string { Length := 25 for _, r := range R { if len(r.Name) > Length { @@ -188,11 +188,11 @@ func FormarPrint(message string) { } // 去重 tempList = RemoveDuplicates(tempList) - // 打印整体文本 + var res strings.Builder for _, i := range tempList { - fmt.Printf(i) + res.WriteString(i) } - + return res.String() } func Excute(F func(c *http.Client) model.Result, c *http.Client, useProgressBar bool) { @@ -545,7 +545,8 @@ func IPV6Multination() [](func(c *http.Client) model.Result) { return FuncList } -func finallyPrintResult(language, netType string) { +func finallyPrintResult(language, netType string) string { + var result string getPlatformName := func(multi bool, TW, HK, JP, KR, NA, SA, EU, AFR, OCEA, SPORT bool) string { if multi { if TW && !HK && !JP && !KR && !NA && !SA && !EU && !AFR && !OCEA && !SPORT { @@ -604,9 +605,9 @@ func finallyPrintResult(language, netType string) { if language == "zh" { if netType == "ipv4" || netType == "" { - FormarPrint(platformName) + result += FormarPrint(platformName) } else if netType == "ipv6" { - FormarPrint("跨国平台") + result += FormarPrint("跨国平台") } } else if language == "en" { if netType == "ipv4" || netType == "" { @@ -634,11 +635,12 @@ func finallyPrintResult(language, netType string) { "体育平台": "Sports", "所有平台": "All Platform", } - FormarPrint(enPlatformName[platformName]) + result += FormarPrint(enPlatformName[platformName]) } else if netType == "ipv6" { - FormarPrint("Global") + result += FormarPrint("Global") } } + return result } func SwitchOptions(c string) { @@ -807,7 +809,7 @@ func getFuncList() [](func(c *http.Client) model.Result) { return funcList } -func RunTests(client *http.Client, ipVersion, language string, useProgressBar bool) { +func RunTests(client *http.Client, ipVersion, language string, useProgressBar bool) string { Names = []string{} total = 0 wg = &sync.WaitGroup{} @@ -823,7 +825,7 @@ func RunTests(client *http.Client, ipVersion, language string, useProgressBar bo if useProgressBar { bar.Finish() } - finallyPrintResult(language, ipVersion) + return finallyPrintResult(language, ipVersion) } func SetupInterface(Iface string) { diff --git a/uts/version.go b/uts/version.go index 9c2a195..929f545 100644 --- a/uts/version.go +++ b/uts/version.go @@ -1,3 +1,3 @@ package uts -const UnlockTestsVersion = "v0.0.9" +const UnlockTestsVersion = "v0.0.10"