diff --git a/utils/http/http.go b/utils/http/http.go index 5eeb1af..55f5a3b 100644 --- a/utils/http/http.go +++ b/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 diff --git a/utils/lo2/lo.go b/utils/lo2/lo.go index f399ed7..9011fe8 100644 --- a/utils/lo2/lo.go +++ b/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 +}