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

@@ -28,18 +28,18 @@ func Close() error {
}
// Error writes v into error log.
func Error(ctx context.Context, v ...interface{}) {
func Error(ctx context.Context, v ...any) {
getLogger(ctx).Error(v...)
}
// Errorf writes v with format into error log.
func Errorf(ctx context.Context, format string, v ...interface{}) {
func Errorf(ctx context.Context, format string, v ...any) {
getLogger(ctx).Errorf(fmt.Errorf(format, v...).Error())
}
// Errorv writes v into error log with json content.
// No call stack attached, because not elegant to pack the messages.
func Errorv(ctx context.Context, v interface{}) {
func Errorv(ctx context.Context, v any) {
getLogger(ctx).Errorv(v)
}
@@ -49,22 +49,22 @@ func Errorw(ctx context.Context, msg string, fields ...LogField) {
}
// Field returns a LogField for the given key and value.
func Field(key string, value interface{}) LogField {
func Field(key string, value any) LogField {
return logx.Field(key, value)
}
// Info writes v into access log.
func Info(ctx context.Context, v ...interface{}) {
func Info(ctx context.Context, v ...any) {
getLogger(ctx).Info(v...)
}
// Infof writes v with format into access log.
func Infof(ctx context.Context, format string, v ...interface{}) {
func Infof(ctx context.Context, format string, v ...any) {
getLogger(ctx).Infof(format, v...)
}
// Infov writes v into access log with json content.
func Infov(ctx context.Context, v interface{}) {
func Infov(ctx context.Context, v any) {
getLogger(ctx).Infov(v)
}
@@ -97,17 +97,17 @@ func SetUp(c LogConf) error {
}
// Slow writes v into slow log.
func Slow(ctx context.Context, v ...interface{}) {
func Slow(ctx context.Context, v ...any) {
getLogger(ctx).Slow(v...)
}
// Slowf writes v with format into slow log.
func Slowf(ctx context.Context, format string, v ...interface{}) {
func Slowf(ctx context.Context, format string, v ...any) {
getLogger(ctx).Slowf(format, v...)
}
// Slowv writes v into slow log with json content.
func Slowv(ctx context.Context, v interface{}) {
func Slowv(ctx context.Context, v any) {
getLogger(ctx).Slowv(v)
}

View File

@@ -26,7 +26,7 @@ func TestAddGlobalFields(t *testing.T) {
AddGlobalFields(Field("a", "1"), Field("b", "2"))
AddGlobalFields(Field("c", "3"))
Info(context.Background(), "world")
var m map[string]interface{}
var m map[string]any
assert.NoError(t, json.Unmarshal(buf.Bytes(), &m))
assert.Equal(t, "1", m["a"])
assert.Equal(t, "2", m["b"])