Chore: use any rather than interface{} (#74066)

This commit is contained in:
Ryan McKinley
2023-08-30 18:46:47 +03:00
committed by GitHub
parent 3e272d2bda
commit 025b2f3011
525 changed files with 2528 additions and 2528 deletions
+7 -7
View File
@@ -24,16 +24,16 @@ var ErrMaximumRetriesReached = errutil.Internal("sqlstore.max-retries-reached")
type DBSession struct {
*xorm.Session
transactionOpen bool
events []interface{}
events []any
}
type DBTransactionFunc func(sess *DBSession) error
func (sess *DBSession) publishAfterCommit(msg interface{}) {
func (sess *DBSession) publishAfterCommit(msg any) {
sess.events = append(sess.events, msg)
}
func (sess *DBSession) PublishAfterCommit(msg interface{}) {
func (sess *DBSession) PublishAfterCommit(msg any) {
sess.events = append(sess.events, msg)
}
@@ -126,7 +126,7 @@ func (ss *SQLStore) withDbSession(ctx context.Context, engine *xorm.Engine, call
return retryer.Retry(ss.retryOnLocks(ctx, callback, sess, retry), ss.dbCfg.QueryRetries, time.Millisecond*time.Duration(10), time.Second)
}
func (sess *DBSession) InsertId(bean interface{}, dialect migrator.Dialect) error {
func (sess *DBSession) InsertId(bean any, dialect migrator.Dialect) error {
table := sess.DB().Mapper.Obj2Table(getTypeName(bean))
if err := dialect.PreInsertId(table, sess.Session); err != nil {
@@ -143,7 +143,7 @@ func (sess *DBSession) InsertId(bean interface{}, dialect migrator.Dialect) erro
return nil
}
func (sess *DBSession) WithReturningID(driverName string, query string, args []interface{}) (int64, error) {
func (sess *DBSession) WithReturningID(driverName string, query string, args []any) (int64, error) {
supported := driverName != migrator.Postgres
var id int64
if !supported {
@@ -152,7 +152,7 @@ func (sess *DBSession) WithReturningID(driverName string, query string, args []i
return id, err
}
} else {
sqlOrArgs := append([]interface{}{query}, args...)
sqlOrArgs := append([]any{query}, args...)
res, err := sess.Exec(sqlOrArgs...)
if err != nil {
return id, err
@@ -165,7 +165,7 @@ func (sess *DBSession) WithReturningID(driverName string, query string, args []i
return id, nil
}
func getTypeName(bean interface{}) (res string) {
func getTypeName(bean any) (res string) {
t := reflect.TypeOf(bean)
for t.Kind() == reflect.Ptr {
t = t.Elem()