From daaee0a7d1c129deaa93deb60c2c51a28370ff1e Mon Sep 17 00:00:00 2001 From: Leon Klingele Date: Sat, 9 Sep 2023 00:10:22 +0200 Subject: [PATCH] all: bring back Go <= 1.18 support --- .golangci.yml | 2 +- ctx_test.go | 6 +++--- middleware/logger/config.go | 2 +- utils/convert.go | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index ee77cd0806b..58ae853e9b4 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -194,7 +194,7 @@ linters-settings: http-status-code: true time-weekday: true time-month: true - time-layout: true + # time-layout: true crypto-hash: true default-rpc-path: true os-dev-null: true diff --git a/ctx_test.go b/ctx_test.go index c37851213a0..4f9f2e3aa0a 100644 --- a/ctx_test.go +++ b/ctx_test.go @@ -640,7 +640,7 @@ func Test_Ctx_BodyParser_WithSetParserDecoder(t *testing.T) { type CustomTime time.Time timeConverter := func(value string) reflect.Value { - if v, err := time.Parse(time.DateOnly, value); err == nil { + if v, err := time.Parse("2006-01-02", value); err == nil { return reflect.ValueOf(v) } return reflect.Value{} @@ -4196,7 +4196,7 @@ func Test_Ctx_QueryParser_WithSetParserDecoder(t *testing.T) { type NonRFCTime time.Time nonRFCConverter := func(value string) reflect.Value { - if v, err := time.Parse(time.DateOnly, value); err == nil { + if v, err := time.Parse("2006-01-02", value); err == nil { return reflect.ValueOf(v) } return reflect.Value{} @@ -4452,7 +4452,7 @@ func Test_Ctx_ReqHeaderParser_WithSetParserDecoder(t *testing.T) { type NonRFCTime time.Time nonRFCConverter := func(value string) reflect.Value { - if v, err := time.Parse(time.DateOnly, value); err == nil { + if v, err := time.Parse("2006-01-02", value); err == nil { return reflect.ValueOf(v) } return reflect.Value{} diff --git a/middleware/logger/config.go b/middleware/logger/config.go index a8aa958dfde..5b91a065ee9 100644 --- a/middleware/logger/config.go +++ b/middleware/logger/config.go @@ -87,7 +87,7 @@ var ConfigDefault = Config{ Next: nil, Done: nil, Format: "[${time}] ${status} - ${latency} ${method} ${path}\n", - TimeFormat: time.TimeOnly, + TimeFormat: "15:04:05", TimeZone: "Local", TimeInterval: 500 * time.Millisecond, Output: os.Stdout, diff --git a/utils/convert.go b/utils/convert.go index b3582edf556..0b99b36f134 100644 --- a/utils/convert.go +++ b/utils/convert.go @@ -106,7 +106,7 @@ func ToString(arg interface{}, timeFormat ...string) string { if len(timeFormat) > 0 { return v.Format(timeFormat[0]) } - return v.Format(time.DateTime) + return v.Format("2006-01-02 15:04:05") case reflect.Value: return ToString(v.Interface(), timeFormat...) case fmt.Stringer: