mirror of
https://github.com/FloatTech/zbpdata.git
synced 2024-11-17 17:47:14 +09:00
feat: 改为并行上传
This commit is contained in:
parent
3b9009e90f
commit
ab10aa8a6b
11
main.go
11
main.go
@ -10,6 +10,7 @@ import (
|
||||
"io/fs"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
"unicode"
|
||||
"unsafe"
|
||||
|
||||
@ -44,12 +45,18 @@ func main() {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer r.Close()
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(len(files))
|
||||
for i, fn := range files {
|
||||
fmt.Println("set", "data/"+fn, "=", hex.EncodeToString(helper.StringToBytes(md5s[i])))
|
||||
go func(i int, fn string) {
|
||||
defer wg.Done()
|
||||
err = r.Set("data/"+fn, md5s[i])
|
||||
fmt.Println("set", "data/"+fn, "=", hex.EncodeToString(helper.StringToBytes(md5s[i])))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}(i, fn)
|
||||
}
|
||||
r.Close()
|
||||
wg.Wait()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user