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)