Replace interface{} with any (#25686)

Result of running `perl -p -i -e 's#interface\{\}#any#g' **/*` and `make fmt`.

Basically the same [as golang did](2580d0e08d).
This commit is contained in:
silverwind 2023-07-04 20:36:08 +02:00 committed by GitHub
parent 00dbba7f42
commit 88f835192d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
233 changed files with 727 additions and 727 deletions

View file

@ -37,7 +37,7 @@ func (w SilentWrap) Unwrap() error {
}
// NewSilentWrapErrorf returns an error that formats as the given text but unwraps as the provided error
func NewSilentWrapErrorf(unwrap error, message string, args ...interface{}) error {
func NewSilentWrapErrorf(unwrap error, message string, args ...any) error {
if len(args) == 0 {
return SilentWrap{Message: message, Err: unwrap}
}
@ -45,21 +45,21 @@ func NewSilentWrapErrorf(unwrap error, message string, args ...interface{}) erro
}
// NewInvalidArgumentErrorf returns an error that formats as the given text but unwraps as an ErrInvalidArgument
func NewInvalidArgumentErrorf(message string, args ...interface{}) error {
func NewInvalidArgumentErrorf(message string, args ...any) error {
return NewSilentWrapErrorf(ErrInvalidArgument, message, args...)
}
// NewPermissionDeniedErrorf returns an error that formats as the given text but unwraps as an ErrPermissionDenied
func NewPermissionDeniedErrorf(message string, args ...interface{}) error {
func NewPermissionDeniedErrorf(message string, args ...any) error {
return NewSilentWrapErrorf(ErrPermissionDenied, message, args...)
}
// NewAlreadyExistErrorf returns an error that formats as the given text but unwraps as an ErrAlreadyExist
func NewAlreadyExistErrorf(message string, args ...interface{}) error {
func NewAlreadyExistErrorf(message string, args ...any) error {
return NewSilentWrapErrorf(ErrAlreadyExist, message, args...)
}
// NewNotExistErrorf returns an error that formats as the given text but unwraps as an ErrNotExist
func NewNotExistErrorf(message string, args ...interface{}) error {
func NewNotExistErrorf(message string, args ...any) error {
return NewSilentWrapErrorf(ErrNotExist, message, args...)
}

View file

@ -9,7 +9,7 @@ import (
)
// PackData uses gob to encode the given data in sequence
func PackData(data ...interface{}) ([]byte, error) {
func PackData(data ...any) ([]byte, error) {
var buf bytes.Buffer
enc := gob.NewEncoder(&buf)
for _, datum := range data {
@ -21,7 +21,7 @@ func PackData(data ...interface{}) ([]byte, error) {
}
// UnpackData uses gob to decode the given data in sequence
func UnpackData(buf []byte, data ...interface{}) error {
func UnpackData(buf []byte, data ...any) error {
r := bytes.NewReader(buf)
enc := gob.NewDecoder(r)
for _, datum := range data {

View file

@ -7,7 +7,7 @@ import "reflect"
// PaginateSlice cut a slice as per pagination options
// if page = 0 it do not paginate
func PaginateSlice(list interface{}, page, pageSize int) interface{} {
func PaginateSlice(list any, page, pageSize int) any {
if page <= 0 || pageSize <= 0 {
return list
}

View file

@ -39,10 +39,10 @@ type RotatingFileWriter struct {
cancelReleaseReopen func()
}
var ErrorPrintf func(format string, args ...interface{})
var ErrorPrintf func(format string, args ...any)
// errorf tries to print error messages. Since this writer could be used by a logger system, this is the last chance to show the error in some cases
func errorf(format string, args ...interface{}) {
func errorf(format string, args ...any) {
if ErrorPrintf != nil {
ErrorPrintf("rotatingfilewriter: "+format+"\n", args...)
}

View file

@ -174,7 +174,7 @@ func ToTitleCaseNoLower(s string) string {
}
// ToInt64 transform a given int into int64.
func ToInt64(number interface{}) (int64, error) {
func ToInt64(number any) (int64, error) {
var value int64
switch v := number.(type) {
case int:
@ -216,7 +216,7 @@ func ToInt64(number interface{}) (int64, error) {
}
// ToFloat64 transform a given int into float64.
func ToFloat64(number interface{}) (float64, error) {
func ToFloat64(number any) (float64, error) {
var value float64
switch v := number.(type) {
case int: