浏览代码

增加工具函数

pull/47/head
Sydonian 1年前
父节点
当前提交
5334f543e9
共有 2 个文件被更改,包括 8 次插入11 次删除
  1. +1
    -11
      utils/http/http.go
  2. +7
    -0
      utils/lo2/lo.go

+ 1
- 11
utils/http/http.go 查看文件

@@ -6,13 +6,11 @@ import (
"io"
"mime"
"mime/multipart"
"net"
"net/http"
"net/textproto"
ul "net/url"
"reflect"
"strings"
"time"

"github.com/mitchellh/mapstructure"
"gitlink.org.cn/cloudream/common/pkgs/iterator"
@@ -28,15 +26,7 @@ const (
ContentTypeOctetStream = "application/octet-stream"
)

var defaultClient = http.Client{
Timeout: time.Second * 5,
Transport: &http.Transport{
DialContext: (&net.Dialer{
Timeout: time.Second * 5,
KeepAlive: 0, // 修改为 0 可以生效
}).DialContext,
},
}
var defaultClient = http.DefaultClient

type RequestParam struct {
Header any


+ 7
- 0
utils/lo2/lo.go 查看文件

@@ -22,3 +22,10 @@ func RemoveAt[T any](arr []T, index int) []T {
func ArrayClone[T any](arr []T) []T {
return append([]T{}, arr...)
}

func Insert[T any](arr []T, index int, item T) []T {
arr = append(arr, item)
copy(arr[index+1:], arr[index:])
arr[index] = item
return arr
}

正在加载...
取消
保存