From 4b25cd5c1b62c4be63abe5108f468046df20c025 Mon Sep 17 00:00:00 2001 From: giaogiao Date: Mon, 31 Jul 2023 17:46:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E5=AE=9E=E7=8E=B0=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E9=87=87=E7=94=A8go=20=E5=8D=8F=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 2b6f453..2f1808d 100644 --- a/main.go +++ b/main.go @@ -2,7 +2,7 @@ * @Author: giaogiao giaogiao * @Date: 2023-07-28 08:53:13 * @LastEditors: giaogiao giaogiao - * @LastEditTime: 2023-07-31 16:50:10 + * @LastEditTime: 2023-07-31 17:32:36 * @FilePath: \go\main.go * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ @@ -17,6 +17,7 @@ import ( "os" "strconv" "strings" + "sync" "time" "github.com/parnurzeal/gorequest" @@ -53,15 +54,20 @@ func read_configuration_file() { fmt.Println(err) return } + //fmt.Println(len(tooltt.Node))求结构体数组大小 } func read_a_file(node *[]Node) { + var wg sync.WaitGroup + wg.Add(len(*node)) for _, item := range *node { // fmt.Println(item.Remarks, item.Country, item.Port) - text_url(item.Remarks, item.Country, item.Port) + go text_url(item.Remarks, item.Country, item.Port, wg.Done) } + wg.Wait() } -func text_url(remarks string, country string, port int) { +func text_url(remarks string, country string, port int, done func()) { + defer done() var port_string string = strconv.Itoa(port) setup.CwLog().Infof("start_testing country:%s,port:%d", country, port) request := gorequest.New().Proxy("socks5://127.0.0.1:" + port_string)