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