diff --git a/.github/workflows/cache.yml b/.github/workflows/cache.yml index f990cc5d..ead760f4 100644 --- a/.github/workflows/cache.yml +++ b/.github/workflows/cache.yml @@ -10,7 +10,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - go: ['1.20.x', '1.21.x'] + go: ['1.21.x'] services: memcached: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7da819b6..27d68140 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macOS-latest, windows-latest] - go: ['1.20.x', '1.21.x'] + go: ['1.21.x'] steps: diff --git a/context.go b/context.go index 059cf2bd..bca6786e 100644 --- a/context.go +++ b/context.go @@ -6,12 +6,12 @@ import ( "fmt" "io" "net/http" + "slices" "strings" "sync" "time" "github.com/issue9/mux/v7/types" - "github.com/issue9/sliceutil" "golang.org/x/text/encoding" "golang.org/x/text/language" "golang.org/x/text/message" @@ -184,7 +184,7 @@ func (b *ContextBuilder) NewContext(w http.ResponseWriter, r *http.Request, rout ctx.inputCharset = inputCharset ctx.languageTag = tag ctx.localePrinter = b.server.Locale().NewPrinter(tag) - ctx.vars = map[any]any{} // TODO: go1.21 可以改为 clear(ctx.vars) + clear(ctx.vars) ctx.logs = b.server.Logs().New(map[string]any{b.requestIDKey: id}) return ctx @@ -300,7 +300,7 @@ func (ctx *Context) LocalePrinter() *message.Printer { return ctx.localePrinter func (ctx *Context) LanguageTag() language.Tag { return ctx.languageTag } func (ctx *Context) Free() { - sliceutil.Reverse(ctx.exits) // TODO: go1.21 改为标准库 + slices.Reverse(ctx.exits) for _, exit := range ctx.exits { exit(ctx, ctx.status) } diff --git a/go.mod b/go.mod index 6256e5f2..c1082039 100644 --- a/go.mod +++ b/go.mod @@ -33,4 +33,4 @@ require ( golang.org/x/sys v0.14.0 // indirect ) -go 1.20 +go 1.21 diff --git a/server/server.go b/server/server.go index eb04cfef..69914b04 100644 --- a/server/server.go +++ b/server/server.go @@ -9,12 +9,12 @@ import ( "context" "errors" "net/http" + "slices" "sync" "time" "github.com/issue9/config" "github.com/issue9/mux/v7/group" - "github.com/issue9/sliceutil" "github.com/issue9/web" "github.com/issue9/web/cache" @@ -145,7 +145,7 @@ func (srv *httpServer) Close(shutdownTimeout time.Duration) { } defer func() { - sliceutil.Reverse(srv.closes) // TODO: go1.21 改为标准库 + slices.Reverse(srv.closes) for _, f := range srv.closes { // 仅在用户主动要关闭时,才关闭服务。 if err1 := f(); err1 != nil { // 出错不退出,继续其它操作。 srv.Logs().ERROR().Error(err1)