From 6d4212b19dbf2dbe49a158d0e6c37f7d8e5e1d57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Sun, 17 Apr 2022 20:34:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=AB=9E=E4=BA=89=E9=80=9F?= =?UTF-8?q?=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 0400cfd..8086ac9 100644 --- a/main.go +++ b/main.go @@ -46,7 +46,7 @@ func main() { panic(err) } defer r.Close() - do1024 := func(k, v string) { + do1024 := func(k, v string) (err error) { for i := 0; i < 1024; i++ { err = r.Set(k, v) if err == nil { @@ -54,12 +54,16 @@ func main() { } fmt.Println("accqiring set lock, retry times:", i) } + return } var wg sync.WaitGroup wg.Add(len(files)) for i, fn := range files { go func(i int, fn string) { - do1024("data/"+fn, md5s[i]) + err := do1024("data/"+fn, md5s[i]) + if err != nil { + panic(err) + } fmt.Println("set", "data/"+fn, "=", hex.EncodeToString(helper.StringToBytes(md5s[i]))) wg.Done() }(i, fn)