feat: 完成了 新建桶; 上传文件(基本功能)
todo: 上传 rename, 上传 public 权限选择 bug: 首次加载 conns list; 上传的时候前缀过滤失败
This commit is contained in:
32
internal/tool/slice.go
Normal file
32
internal/tool/slice.go
Normal file
@ -0,0 +1,32 @@
|
||||
package tool
|
||||
|
||||
import "iter"
|
||||
|
||||
func Bulk[T any](slice []T, size int) iter.Seq2[int, []T] {
|
||||
if size <= 0 {
|
||||
panic("bulk size must be positive")
|
||||
}
|
||||
|
||||
s := make([]T, 0, size)
|
||||
idx := 0
|
||||
return func(yield func(int, []T) bool) {
|
||||
for i := range slice {
|
||||
s = append(s, (slice)[i])
|
||||
if len(s) >= size {
|
||||
|
||||
// send to handle
|
||||
ok := yield(idx, s)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
idx++
|
||||
s = make([]T, 0, size)
|
||||
}
|
||||
}
|
||||
|
||||
if len(s) > 0 {
|
||||
yield(idx, s)
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user