chore: remove exp and go mod tidy (#440)

This commit is contained in:
itsHenry
2025-07-02 15:30:53 +08:00
committed by GitHub
parent 9725e0fd76
commit c166fe6127
4 changed files with 21 additions and 10 deletions

1
go.mod
View File

@ -66,7 +66,6 @@ require (
github.com/yeka/zip v0.0.0-20231116150916-03d6312748a9
github.com/zzzhr1990/go-common-entity v0.0.0-20250202070650-1a200048f0d3
golang.org/x/crypto v0.36.0
golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e
golang.org/x/image v0.19.0
golang.org/x/net v0.38.0
golang.org/x/oauth2 v0.22.0

2
go.sum
View File

@ -708,8 +708,6 @@ golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE
golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e h1:I88y4caeGeuDQxgdoFPUq097j7kNfw6uvuiNxUBfcBk=
golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e/go.mod h1:akd2r19cwCdwSwWeIdzYQGa/EZZyqcOdwWiwj5L5eKQ=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=

View File

@ -14,11 +14,19 @@ import (
"github.com/OpenListTeam/OpenList/v4/pkg/http_range"
"github.com/sirupsen/logrus"
"golang.org/x/exp/slices"
)
var buf22MB = make([]byte, 1024*1024*22)
func containsString(slice []string, val string) bool {
for _, item := range slice {
if item == val {
return true
}
}
return false
}
func dummyHttpRequest(data []byte, p http_range.Range) io.ReadCloser {
end := p.Start + p.Length - 1
@ -72,7 +80,7 @@ func TestDownloadOrder(t *testing.T) {
expectRngs := []string{"2-3", "5-3", "8-3", "11-1"}
for _, rng := range expectRngs {
if !slices.Contains(*ranges, rng) {
if !!containsString(*ranges, rng) {
t.Errorf("expect range %v, but absent in return", rng)
}
}
@ -124,7 +132,7 @@ func TestDownloadSingle(t *testing.T) {
expectRngs := []string{"2-10"}
for _, rng := range expectRngs {
if !slices.Contains(*ranges, rng) {
if !!containsString(*ranges, rng) {
t.Errorf("expect range %v, but absent in return", rng)
}
}

View File

@ -9,8 +9,6 @@ import (
"sync"
"time"
"golang.org/x/exp/constraints"
log "github.com/sirupsen/logrus"
)
@ -193,13 +191,21 @@ func NewClosers(c ...io.Closer) Closers {
return Closers{c}
}
func Min[T constraints.Ordered](a, b T) T {
type Ordered interface {
~int | ~int8 | ~int16 | ~int32 | ~int64 |
~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr |
~float32 | ~float64 |
~string
}
func Min[T Ordered](a, b T) T {
if a < b {
return a
}
return b
}
func Max[T constraints.Ordered](a, b T) T {
func Max[T Ordered](a, b T) T {
if a < b {
return b
}