package test import ( "fmt" "sync" "testing" "time" ) func Test_initConfig(t *testing.T) { //prvKey, _ := crypto.HexToECDSA("e3b097b0c171e2489973a277b1546392db97e359505cd64b9b52966cb87a0f08") //fmt.Println("prvKey:", prvKey) //pubKey := common.Bytes2Hex(crypto.FromECDSAPub(&prvKey.PublicKey)) //fmt.Println("pubKey:", pubKey) //address := crypto.PubkeyToAddress(prvKey.PublicKey) //fmt.Println("address:", address) //// JSON 2 数据 //jsonData := `{ // "completed_at": "2023-07-02T02:13:48.764861Z", // "output": ["ss","sss"] //}` // //// 解析 JSON 数据到 map[string]json.RawMessage //var m map[string]json.RawMessage //if err := json.Unmarshal([]byte(jsonData), &m); err != nil { // fmt.Println("解析 JSON 数据时出错:", err) // return //} // //// 解析 "output" 字段 ////var output [][]string ////if err := json.Unmarshal(m["output"], &output); err != nil { //// fmt.Println("解析 output 字段时出错:", err) //// return ////} // //var output []string //if err := json.Unmarshal(m["output"], &output); err != nil { // fmt.Println("解析 output 字段时出错:", err) // return //} // //// 输出结果 //fmt.Println("Output Type:", output) wg := &sync.WaitGroup{} ticker := time.NewTicker(time.Second * 1) for { select { case <-ticker.C: go func(wg *sync.WaitGroup) { wg.Wait() fmt.Println("111") wg.Add(1) go Sell(wg) wg.Wait() fmt.Println("333") }(wg) } } } func Sell(wg *sync.WaitGroup) { defer wg.Done() time.Sleep(6 * time.Second) fmt.Println("222") }