chore: change interface{} to any (#2818)

* chore: change interface{} to any

* chore: update goctl version to 1.5.0

* chore: update goctl deps
This commit is contained in:
Kevin Wan
2023-01-24 16:32:02 +08:00
committed by GitHub
parent 7e0ac77139
commit ae87114282
221 changed files with 1910 additions and 2207 deletions

View File

@@ -30,7 +30,7 @@ func TestError(t *testing.T) {
tests := []struct {
name string
input string
errorHandler func(error) (int, interface{})
errorHandler func(error) (int, any)
expectHasBody bool
expectBody string
expectCode int
@@ -45,7 +45,7 @@ func TestError(t *testing.T) {
{
name: "customized error handler return string",
input: body,
errorHandler: func(err error) (int, interface{}) {
errorHandler: func(err error) (int, any) {
return http.StatusForbidden, err.Error()
},
expectHasBody: true,
@@ -55,7 +55,7 @@ func TestError(t *testing.T) {
{
name: "customized error handler return error",
input: body,
errorHandler: func(err error) (int, interface{}) {
errorHandler: func(err error) (int, any) {
return http.StatusForbidden, err
},
expectHasBody: true,
@@ -65,7 +65,7 @@ func TestError(t *testing.T) {
{
name: "customized error handler return nil",
input: body,
errorHandler: func(err error) (int, interface{}) {
errorHandler: func(err error) (int, any) {
return http.StatusForbidden, nil
},
expectHasBody: false,
@@ -174,7 +174,7 @@ func TestWriteJsonMarshalFailed(t *testing.T) {
w := tracedResponseWriter{
headers: make(map[string][]string),
}
WriteJson(&w, http.StatusOK, map[string]interface{}{
WriteJson(&w, http.StatusOK, map[string]any{
"Data": complex(0, 0),
})
assert.Equal(t, http.StatusInternalServerError, w.code)
@@ -225,7 +225,7 @@ func TestErrorCtx(t *testing.T) {
tests := []struct {
name string
input string
errorHandlerCtx func(context.Context, error) (int, interface{})
errorHandlerCtx func(context.Context, error) (int, any)
expectHasBody bool
expectBody string
expectCode int
@@ -240,7 +240,7 @@ func TestErrorCtx(t *testing.T) {
{
name: "customized error handler return string",
input: body,
errorHandlerCtx: func(ctx context.Context, err error) (int, interface{}) {
errorHandlerCtx: func(ctx context.Context, err error) (int, any) {
return http.StatusForbidden, err.Error()
},
expectHasBody: true,
@@ -250,7 +250,7 @@ func TestErrorCtx(t *testing.T) {
{
name: "customized error handler return error",
input: body,
errorHandlerCtx: func(ctx context.Context, err error) (int, interface{}) {
errorHandlerCtx: func(ctx context.Context, err error) (int, any) {
return http.StatusForbidden, err
},
expectHasBody: true,
@@ -260,7 +260,7 @@ func TestErrorCtx(t *testing.T) {
{
name: "customized error handler return nil",
input: body,
errorHandlerCtx: func(context.Context, error) (int, interface{}) {
errorHandlerCtx: func(context.Context, error) (int, any) {
return http.StatusForbidden, nil
},
expectHasBody: false,
@@ -292,7 +292,7 @@ func TestErrorCtx(t *testing.T) {
})
}
//The current handler is a global event,Set default values to avoid impacting subsequent unit tests
// The current handler is a global event,Set default values to avoid impacting subsequent unit tests
SetErrorHandlerCtx(nil)
}
@@ -322,7 +322,7 @@ func TestWriteJsonCtxMarshalFailed(t *testing.T) {
w := tracedResponseWriter{
headers: make(map[string][]string),
}
WriteJsonCtx(context.Background(), &w, http.StatusOK, map[string]interface{}{
WriteJsonCtx(context.Background(), &w, http.StatusOK, map[string]any{
"Data": complex(0, 0),
})
assert.Equal(t, http.StatusInternalServerError, w.code)