Chore: use any rather than interface{} (#74066)
This commit is contained in:
@@ -170,7 +170,7 @@ func WithPublicMessage(message string) BaseOpt {
|
||||
// Errorf creates a new [Error] with Reason and MessageID from [Base],
|
||||
// and Message and Underlying will be populated using the rules of
|
||||
// [fmt.Errorf].
|
||||
func (b Base) Errorf(format string, args ...interface{}) Error {
|
||||
func (b Base) Errorf(format string, args ...any) Error {
|
||||
err := fmt.Errorf(format, args...)
|
||||
|
||||
return Error{
|
||||
@@ -270,7 +270,7 @@ type Error struct {
|
||||
PublicMessage string
|
||||
// PublicPayload provides fields for passing structured data to
|
||||
// construct localized error messages in the client.
|
||||
PublicPayload map[string]interface{}
|
||||
PublicPayload map[string]any
|
||||
// LogLevel provides a suggested level of logging for the error.
|
||||
LogLevel LogLevel
|
||||
}
|
||||
@@ -327,10 +327,10 @@ func (e Error) Is(other error) bool {
|
||||
// PublicError is derived from Error and only contains information
|
||||
// available to the end user.
|
||||
type PublicError struct {
|
||||
StatusCode int `json:"statusCode"`
|
||||
MessageID string `json:"messageId"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Extra map[string]interface{} `json:"extra,omitempty"`
|
||||
StatusCode int `json:"statusCode"`
|
||||
MessageID string `json:"messageId"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Extra map[string]any `json:"extra,omitempty"`
|
||||
}
|
||||
|
||||
// Public returns a subset of the error with non-sensitive information
|
||||
|
||||
@@ -17,16 +17,16 @@ const (
|
||||
// to avoid having to depend on other packages in the module so that
|
||||
// there's no risk of circular dependencies.
|
||||
type LogInterface interface {
|
||||
Debug(msg string, ctx ...interface{})
|
||||
Info(msg string, ctx ...interface{})
|
||||
Warn(msg string, ctx ...interface{})
|
||||
Error(msg string, ctx ...interface{})
|
||||
Debug(msg string, ctx ...any)
|
||||
Info(msg string, ctx ...any)
|
||||
Warn(msg string, ctx ...any)
|
||||
Error(msg string, ctx ...any)
|
||||
}
|
||||
|
||||
func (l LogLevel) LogFunc(logger LogInterface) func(msg string, ctx ...interface{}) {
|
||||
func (l LogLevel) LogFunc(logger LogInterface) func(msg string, ctx ...any) {
|
||||
switch l {
|
||||
case LevelNever:
|
||||
return func(_ string, _ ...interface{}) {}
|
||||
return func(_ string, _ ...any) {}
|
||||
case LevelDebug:
|
||||
return logger.Debug
|
||||
case LevelInfo:
|
||||
|
||||
@@ -17,8 +17,8 @@ type Template struct {
|
||||
// TemplateData contains data for constructing an Error based on a
|
||||
// Template.
|
||||
type TemplateData struct {
|
||||
Private map[string]interface{}
|
||||
Public map[string]interface{}
|
||||
Private map[string]any
|
||||
Public map[string]any
|
||||
Error error
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
func TestTemplate(t *testing.T) {
|
||||
tmpl := errutil.Internal("template.sampleError").MustTemplate("[{{ .Public.user }}] got error: {{ .Error }}")
|
||||
err := tmpl.Build(errutil.TemplateData{
|
||||
Public: map[string]interface{}{
|
||||
Public: map[string]any{
|
||||
"user": "grot the bot",
|
||||
},
|
||||
Error: errors.New("oh noes"),
|
||||
@@ -35,7 +35,7 @@ func ExampleTemplate() {
|
||||
|
||||
// Construct an error based on the template.
|
||||
err := tmpl.Build(errutil.TemplateData{
|
||||
Public: map[string]interface{}{
|
||||
Public: map[string]any{
|
||||
"user": "grot the bot",
|
||||
},
|
||||
Error: errors.New("oh noes"),
|
||||
@@ -58,7 +58,7 @@ func ExampleTemplate_public() {
|
||||
// Construct an error based on the template.
|
||||
//nolint:errorlint
|
||||
err := tmpl.Build(errutil.TemplateData{
|
||||
Public: map[string]interface{}{
|
||||
Public: map[string]any{
|
||||
"user": "grot the bot",
|
||||
},
|
||||
Error: errors.New("oh noes"),
|
||||
|
||||
Reference in New Issue
Block a user