loading up the forgejo repo on tangled to test page performance

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](https://github.com/golang/go/commit/2580d0e08d5e9f979b943758d3c49877fb2324cb).

authored by silverwind and committed by GitHub 88f83519 00dbba7f

Changed files
+727 -727
build
cmd
models
modules
routers
services
auth
source
context
cron
externalaccount
lfs
mailer
migrations
mirror
packages
repository
files
task
tests
+1 -1
build/code-batch-process.go
··· 25 25 26 26 var optionLogVerbose bool 27 27 28 - func logVerbose(msg string, args ...interface{}) { 28 + func logVerbose(msg string, args ...any) { 29 29 if optionLogVerbose { 30 30 log.Printf(msg, args...) 31 31 }
+3 -3
cmd/cert.go
··· 63 63 }, 64 64 } 65 65 66 - func publicKey(priv interface{}) interface{} { 66 + func publicKey(priv any) any { 67 67 switch k := priv.(type) { 68 68 case *rsa.PrivateKey: 69 69 return &k.PublicKey ··· 74 74 } 75 75 } 76 76 77 - func pemBlockForKey(priv interface{}) *pem.Block { 77 + func pemBlockForKey(priv any) *pem.Block { 78 78 switch k := priv.(type) { 79 79 case *rsa.PrivateKey: 80 80 return &pem.Block{Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(k)} ··· 94 94 return err 95 95 } 96 96 97 - var priv interface{} 97 + var priv any 98 98 var err error 99 99 switch c.String("ecdsa-curve") { 100 100 case "":
+2 -2
cmd/dump.go
··· 161 161 }, 162 162 } 163 163 164 - func fatal(format string, args ...interface{}) { 164 + func fatal(format string, args ...any) { 165 165 fmt.Fprintf(os.Stderr, format+"\n", args...) 166 166 log.Fatal(format, args...) 167 167 } ··· 236 236 return err 237 237 } 238 238 239 - var iface interface{} 239 + var iface any 240 240 if fileName == "-" { 241 241 iface, err = archiver.ByExtension(fmt.Sprintf(".%s", outType)) 242 242 } else {
+3 -3
cmd/manager_logging.go
··· 178 178 defer cancel() 179 179 180 180 setup(ctx, c.Bool("debug")) 181 - vals := map[string]interface{}{} 181 + vals := map[string]any{} 182 182 mode := "conn" 183 183 vals["net"] = "tcp" 184 184 if c.IsSet("protocol") { ··· 208 208 defer cancel() 209 209 210 210 setup(ctx, c.Bool("debug")) 211 - vals := map[string]interface{}{} 211 + vals := map[string]any{} 212 212 mode := "file" 213 213 if c.IsSet("filename") { 214 214 vals["filename"] = c.String("filename") ··· 236 236 return commonAddLogger(c, mode, vals) 237 237 } 238 238 239 - func commonAddLogger(c *cli.Context, mode string, vals map[string]interface{}) error { 239 + func commonAddLogger(c *cli.Context, mode string, vals map[string]any) error { 240 240 if len(c.String("level")) > 0 { 241 241 vals["level"] = log.LevelFromString(c.String("level")).String() 242 242 }
+1 -1
cmd/serv.go
··· 95 95 96 96 // fail prints message to stdout, it's mainly used for git serv and git hook commands. 97 97 // The output will be passed to git client and shown to user. 98 - func fail(ctx context.Context, userMessage, logMsgFmt string, args ...interface{}) error { 98 + func fail(ctx context.Context, userMessage, logMsgFmt string, args ...any) error { 99 99 if userMessage == "" { 100 100 userMessage = "Internal Server Error (no specific error)" 101 101 }
+1 -1
models/admin/task.go
··· 44 44 // TranslatableMessage represents JSON struct that can be translated with a Locale 45 45 type TranslatableMessage struct { 46 46 Format string 47 - Args []interface{} `json:"omitempty"` 47 + Args []any `json:"omitempty"` 48 48 } 49 49 50 50 // LoadRepo loads repository of the task
+2 -2
models/asymkey/ssh_key_authorized_keys.go
··· 47 47 // AuthorizedStringForKey creates the authorized keys string appropriate for the provided key 48 48 func AuthorizedStringForKey(key *PublicKey) string { 49 49 sb := &strings.Builder{} 50 - _ = setting.SSH.AuthorizedKeysCommandTemplateTemplate.Execute(sb, map[string]interface{}{ 50 + _ = setting.SSH.AuthorizedKeysCommandTemplateTemplate.Execute(sb, map[string]any{ 51 51 "AppPath": util.ShellEscape(setting.AppPath), 52 52 "AppWorkPath": util.ShellEscape(setting.AppWorkPath), 53 53 "CustomConf": util.ShellEscape(setting.CustomConf), ··· 175 175 176 176 // RegeneratePublicKeys regenerates the authorized_keys file 177 177 func RegeneratePublicKeys(ctx context.Context, t io.StringWriter) error { 178 - if err := db.GetEngine(ctx).Where("type != ?", KeyTypePrincipal).Iterate(new(PublicKey), func(idx int, bean interface{}) (err error) { 178 + if err := db.GetEngine(ctx).Where("type != ?", KeyTypePrincipal).Iterate(new(PublicKey), func(idx int, bean any) (err error) { 179 179 _, err = t.WriteString((bean.(*PublicKey)).AuthorizedString()) 180 180 return err 181 181 }); err != nil {
+1 -1
models/asymkey/ssh_key_authorized_principals.go
··· 97 97 } 98 98 99 99 func regeneratePrincipalKeys(ctx context.Context, t io.StringWriter) error { 100 - if err := db.GetEngine(ctx).Where("type = ?", KeyTypePrincipal).Iterate(new(PublicKey), func(idx int, bean interface{}) (err error) { 100 + if err := db.GetEngine(ctx).Where("type = ?", KeyTypePrincipal).Iterate(new(PublicKey), func(idx int, bean any) (err error) { 101 101 _, err = t.WriteString((bean.(*PublicKey)).AuthorizedString()) 102 102 return err 103 103 }); err != nil {
+11 -11
models/db/context.go
··· 52 52 } 53 53 54 54 // Value shadows Value for context.Context but allows us to get ourselves and an Engined object 55 - func (ctx *Context) Value(key interface{}) interface{} { 55 + func (ctx *Context) Value(key any) any { 56 56 if key == enginedContextKey { 57 57 return ctx 58 58 } ··· 163 163 } 164 164 165 165 // Insert inserts records into database 166 - func Insert(ctx context.Context, beans ...interface{}) error { 166 + func Insert(ctx context.Context, beans ...any) error { 167 167 _, err := GetEngine(ctx).Insert(beans...) 168 168 return err 169 169 } 170 170 171 171 // Exec executes a sql with args 172 - func Exec(ctx context.Context, sqlAndArgs ...interface{}) (sql.Result, error) { 172 + func Exec(ctx context.Context, sqlAndArgs ...any) (sql.Result, error) { 173 173 return GetEngine(ctx).Exec(sqlAndArgs...) 174 174 } 175 175 176 176 // GetByBean filled empty fields of the bean according non-empty fields to query in database. 177 - func GetByBean(ctx context.Context, bean interface{}) (bool, error) { 177 + func GetByBean(ctx context.Context, bean any) (bool, error) { 178 178 return GetEngine(ctx).Get(bean) 179 179 } 180 180 181 181 // DeleteByBean deletes all records according non-empty fields of the bean as conditions. 182 - func DeleteByBean(ctx context.Context, bean interface{}) (int64, error) { 182 + func DeleteByBean(ctx context.Context, bean any) (int64, error) { 183 183 return GetEngine(ctx).Delete(bean) 184 184 } 185 185 186 186 // DeleteByID deletes the given bean with the given ID 187 - func DeleteByID(ctx context.Context, id int64, bean interface{}) (int64, error) { 187 + func DeleteByID(ctx context.Context, id int64, bean any) (int64, error) { 188 188 return GetEngine(ctx).ID(id).NoAutoTime().Delete(bean) 189 189 } 190 190 ··· 203 203 204 204 // DecrByIDs decreases the given column for entities of the "bean" type with one of the given ids by one 205 205 // Timestamps of the entities won't be updated 206 - func DecrByIDs(ctx context.Context, ids []int64, decrCol string, bean interface{}) error { 206 + func DecrByIDs(ctx context.Context, ids []int64, decrCol string, bean any) error { 207 207 _, err := GetEngine(ctx).Decr(decrCol).In("id", ids).NoAutoCondition().NoAutoTime().Update(bean) 208 208 return err 209 209 } 210 210 211 211 // DeleteBeans deletes all given beans, beans must contain delete conditions. 212 - func DeleteBeans(ctx context.Context, beans ...interface{}) (err error) { 212 + func DeleteBeans(ctx context.Context, beans ...any) (err error) { 213 213 e := GetEngine(ctx) 214 214 for i := range beans { 215 215 if _, err = e.Delete(beans[i]); err != nil { ··· 220 220 } 221 221 222 222 // TruncateBeans deletes all given beans, beans may contain delete conditions. 223 - func TruncateBeans(ctx context.Context, beans ...interface{}) (err error) { 223 + func TruncateBeans(ctx context.Context, beans ...any) (err error) { 224 224 e := GetEngine(ctx) 225 225 for i := range beans { 226 226 if _, err = e.Truncate(beans[i]); err != nil { ··· 231 231 } 232 232 233 233 // CountByBean counts the number of database records according non-empty fields of the bean as conditions. 234 - func CountByBean(ctx context.Context, bean interface{}) (int64, error) { 234 + func CountByBean(ctx context.Context, bean any) (int64, error) { 235 235 return GetEngine(ctx).Count(bean) 236 236 } 237 237 238 238 // TableName returns the table name according a bean object 239 - func TableName(bean interface{}) string { 239 + func TableName(bean any) string { 240 240 return x.TableName(bean) 241 241 } 242 242
+31 -31
models/db/engine.go
··· 25 25 26 26 var ( 27 27 x *xorm.Engine 28 - tables []interface{} 28 + tables []any 29 29 initFuncs []func() error 30 30 31 31 // HasEngine specifies if we have a xorm.Engine ··· 34 34 35 35 // Engine represents a xorm engine or session. 36 36 type Engine interface { 37 - Table(tableNameOrBean interface{}) *xorm.Session 38 - Count(...interface{}) (int64, error) 39 - Decr(column string, arg ...interface{}) *xorm.Session 40 - Delete(...interface{}) (int64, error) 41 - Truncate(...interface{}) (int64, error) 42 - Exec(...interface{}) (sql.Result, error) 43 - Find(interface{}, ...interface{}) error 44 - Get(beans ...interface{}) (bool, error) 45 - ID(interface{}) *xorm.Session 46 - In(string, ...interface{}) *xorm.Session 47 - Incr(column string, arg ...interface{}) *xorm.Session 48 - Insert(...interface{}) (int64, error) 49 - Iterate(interface{}, xorm.IterFunc) error 50 - Join(joinOperator string, tablename, condition interface{}, args ...interface{}) *xorm.Session 51 - SQL(interface{}, ...interface{}) *xorm.Session 52 - Where(interface{}, ...interface{}) *xorm.Session 37 + Table(tableNameOrBean any) *xorm.Session 38 + Count(...any) (int64, error) 39 + Decr(column string, arg ...any) *xorm.Session 40 + Delete(...any) (int64, error) 41 + Truncate(...any) (int64, error) 42 + Exec(...any) (sql.Result, error) 43 + Find(any, ...any) error 44 + Get(beans ...any) (bool, error) 45 + ID(any) *xorm.Session 46 + In(string, ...any) *xorm.Session 47 + Incr(column string, arg ...any) *xorm.Session 48 + Insert(...any) (int64, error) 49 + Iterate(any, xorm.IterFunc) error 50 + Join(joinOperator string, tablename, condition any, args ...any) *xorm.Session 51 + SQL(any, ...any) *xorm.Session 52 + Where(any, ...any) *xorm.Session 53 53 Asc(colNames ...string) *xorm.Session 54 54 Desc(colNames ...string) *xorm.Session 55 55 Limit(limit int, start ...int) *xorm.Session 56 56 NoAutoTime() *xorm.Session 57 - SumInt(bean interface{}, columnName string) (res int64, err error) 58 - Sync2(...interface{}) error 57 + SumInt(bean any, columnName string) (res int64, err error) 58 + Sync2(...any) error 59 59 Select(string) *xorm.Session 60 - NotIn(string, ...interface{}) *xorm.Session 61 - OrderBy(interface{}, ...interface{}) *xorm.Session 62 - Exist(...interface{}) (bool, error) 60 + NotIn(string, ...any) *xorm.Session 61 + OrderBy(any, ...any) *xorm.Session 62 + Exist(...any) (bool, error) 63 63 Distinct(...string) *xorm.Session 64 - Query(...interface{}) ([]map[string][]byte, error) 64 + Query(...any) ([]map[string][]byte, error) 65 65 Cols(...string) *xorm.Session 66 66 Context(ctx context.Context) *xorm.Session 67 67 Ping() error 68 68 } 69 69 70 70 // TableInfo returns table's information via an object 71 - func TableInfo(v interface{}) (*schemas.Table, error) { 71 + func TableInfo(v any) (*schemas.Table, error) { 72 72 return x.TableInfo(v) 73 73 } 74 74 ··· 78 78 } 79 79 80 80 // RegisterModel registers model, if initfunc provided, it will be invoked after data model sync 81 - func RegisterModel(bean interface{}, initFunc ...func() error) { 81 + func RegisterModel(bean any, initFunc ...func() error) { 82 82 tables = append(tables, bean) 83 83 if len(initFuncs) > 0 && initFunc[0] != nil { 84 84 initFuncs = append(initFuncs, initFunc[0]) ··· 209 209 } 210 210 211 211 // NamesToBean return a list of beans or an error 212 - func NamesToBean(names ...string) ([]interface{}, error) { 213 - beans := []interface{}{} 212 + func NamesToBean(names ...string) ([]any, error) { 213 + beans := []any{} 214 214 if len(names) == 0 { 215 215 beans = append(beans, tables...) 216 216 return beans, nil 217 217 } 218 218 // Need to map provided names to beans... 219 - beanMap := make(map[string]interface{}) 219 + beanMap := make(map[string]any) 220 220 for _, bean := range tables { 221 221 222 222 beanMap[strings.ToLower(reflect.Indirect(reflect.ValueOf(bean)).Type().Name())] = bean ··· 224 224 beanMap[strings.ToLower(x.TableName(bean, true))] = bean 225 225 } 226 226 227 - gotBean := make(map[interface{}]bool) 227 + gotBean := make(map[any]bool) 228 228 for _, name := range names { 229 229 bean, ok := beanMap[strings.ToLower(strings.TrimSpace(name))] 230 230 if !ok { ··· 266 266 } 267 267 268 268 // MaxBatchInsertSize returns the table's max batch insert size 269 - func MaxBatchInsertSize(bean interface{}) int { 269 + func MaxBatchInsertSize(bean any) int { 270 270 t, err := x.TableInfo(bean) 271 271 if err != nil { 272 272 return 50 ··· 286 286 } 287 287 288 288 // GetMaxID will return max id of the table 289 - func GetMaxID(beanOrTableName interface{}) (maxID int64, err error) { 289 + func GetMaxID(beanOrTableName any) (maxID int64, err error) { 290 290 _, err = x.Select("MAX(id)").Table(beanOrTableName).Get(&maxID) 291 291 return maxID, err 292 292 }
+1 -1
models/db/error.go
··· 25 25 } 26 26 27 27 // ErrCancelledf returns an ErrCancelled for the provided format and args 28 - func ErrCancelledf(format string, args ...interface{}) error { 28 + func ErrCancelledf(format string, args ...any) error { 29 29 return ErrCancelled{ 30 30 fmt.Sprintf(format, args...), 31 31 }
+9 -9
models/db/log.go
··· 28 28 const stackLevel = 8 29 29 30 30 // Log a message with defined skip and at logging level 31 - func (l *XORMLogBridge) Log(skip int, level log.Level, format string, v ...interface{}) { 31 + func (l *XORMLogBridge) Log(skip int, level log.Level, format string, v ...any) { 32 32 l.logger.Log(skip+1, level, format, v...) 33 33 } 34 34 35 35 // Debug show debug log 36 - func (l *XORMLogBridge) Debug(v ...interface{}) { 36 + func (l *XORMLogBridge) Debug(v ...any) { 37 37 l.Log(stackLevel, log.DEBUG, "%s", fmt.Sprint(v...)) 38 38 } 39 39 40 40 // Debugf show debug log 41 - func (l *XORMLogBridge) Debugf(format string, v ...interface{}) { 41 + func (l *XORMLogBridge) Debugf(format string, v ...any) { 42 42 l.Log(stackLevel, log.DEBUG, format, v...) 43 43 } 44 44 45 45 // Error show error log 46 - func (l *XORMLogBridge) Error(v ...interface{}) { 46 + func (l *XORMLogBridge) Error(v ...any) { 47 47 l.Log(stackLevel, log.ERROR, "%s", fmt.Sprint(v...)) 48 48 } 49 49 50 50 // Errorf show error log 51 - func (l *XORMLogBridge) Errorf(format string, v ...interface{}) { 51 + func (l *XORMLogBridge) Errorf(format string, v ...any) { 52 52 l.Log(stackLevel, log.ERROR, format, v...) 53 53 } 54 54 55 55 // Info show information level log 56 - func (l *XORMLogBridge) Info(v ...interface{}) { 56 + func (l *XORMLogBridge) Info(v ...any) { 57 57 l.Log(stackLevel, log.INFO, "%s", fmt.Sprint(v...)) 58 58 } 59 59 60 60 // Infof show information level log 61 - func (l *XORMLogBridge) Infof(format string, v ...interface{}) { 61 + func (l *XORMLogBridge) Infof(format string, v ...any) { 62 62 l.Log(stackLevel, log.INFO, format, v...) 63 63 } 64 64 65 65 // Warn show warning log 66 - func (l *XORMLogBridge) Warn(v ...interface{}) { 66 + func (l *XORMLogBridge) Warn(v ...any) { 67 67 l.Log(stackLevel, log.WARN, "%s", fmt.Sprint(v...)) 68 68 } 69 69 70 70 // Warnf show warnning log 71 - func (l *XORMLogBridge) Warnf(format string, v ...interface{}) { 71 + func (l *XORMLogBridge) Warnf(format string, v ...any) { 72 72 l.Log(stackLevel, log.WARN, format, v...) 73 73 } 74 74
+1 -1
models/git/branch.go
··· 355 355 // 4. Update all not merged pull request base branch name 356 356 _, err = sess.Table("pull_request").Where("base_repo_id=? AND base_branch=? AND has_merged=?", 357 357 repo.ID, from, false). 358 - Update(map[string]interface{}{"base_branch": to}) 358 + Update(map[string]any{"base_branch": to}) 359 359 if err != nil { 360 360 return err 361 361 }
+1 -1
models/git/lfs.go
··· 264 264 265 265 sess := db.GetEngine(ctx) 266 266 267 - oids := make([]interface{}, len(metas)) 267 + oids := make([]any, len(metas)) 268 268 oidMap := make(map[string]*LFSMetaObject, len(metas)) 269 269 for i, meta := range metas { 270 270 oids[i] = meta.Oid
+2 -2
models/issues/comment.go
··· 1131 1131 } 1132 1132 if _, err := e.Table("action"). 1133 1133 Where("comment_id = ?", comment.ID). 1134 - Update(map[string]interface{}{ 1134 + Update(map[string]any{ 1135 1135 "is_deleted": true, 1136 1136 }); err != nil { 1137 1137 return err ··· 1156 1156 }), 1157 1157 )). 1158 1158 And("comment.original_author_id = ?", originalAuthorID). 1159 - Update(map[string]interface{}{ 1159 + Update(map[string]any{ 1160 1160 "poster_id": posterID, 1161 1161 "original_author": "", 1162 1162 "original_author_id": 0,
+3 -3
models/issues/issue.go
··· 714 714 715 715 _, err = db.GetEngine(ctx).Table("issue"). 716 716 Where("id = ?", issue.ID). 717 - Update(map[string]interface{}{ 717 + Update(map[string]any{ 718 718 "pin_order": maxPin + 1, 719 719 }) 720 720 if err != nil { ··· 750 750 751 751 _, err = db.GetEngine(ctx).Table("issue"). 752 752 Where("id = ?", issue.ID). 753 - Update(map[string]interface{}{ 753 + Update(map[string]any{ 754 754 "pin_order": 0, 755 755 }) 756 756 if err != nil { ··· 822 822 823 823 _, err = db.GetEngine(dbctx).Table("issue"). 824 824 Where("id = ?", issue.ID). 825 - Update(map[string]interface{}{ 825 + Update(map[string]any{ 826 826 "pin_order": newPosition, 827 827 }) 828 828 if err != nil {
+3 -3
models/issues/issue_update.go
··· 511 511 } 512 512 513 513 // DeleteInIssue delete records in beans with external key issue_id = ? 514 - func DeleteInIssue(ctx context.Context, issueID int64, beans ...interface{}) error { 514 + func DeleteInIssue(ctx context.Context, issueID int64, beans ...any) error { 515 515 e := db.GetEngine(ctx) 516 516 for _, bean := range beans { 517 517 if _, err := e.In("issue_id", issueID).Delete(bean); err != nil { ··· 673 673 _, err := db.GetEngine(db.DefaultContext).Table("issue"). 674 674 Where("repo_id IN (SELECT id FROM repository WHERE original_service_type = ?)", gitServiceType). 675 675 And("original_author_id = ?", originalAuthorID). 676 - Update(map[string]interface{}{ 676 + Update(map[string]any{ 677 677 "poster_id": posterID, 678 678 "original_author": "", 679 679 "original_author_id": 0, ··· 686 686 _, err := db.GetEngine(db.DefaultContext).Table("reaction"). 687 687 Where("original_author_id = ?", originalAuthorID). 688 688 And(migratedIssueCond(gitServiceType)). 689 - Update(map[string]interface{}{ 689 + Update(map[string]any{ 690 690 "user_id": userID, 691 691 "original_author": "", 692 692 "original_author_id": 0,
+1 -1
models/issues/review.go
··· 1111 1111 _, err := db.GetEngine(db.DefaultContext).Table("review"). 1112 1112 Where("original_author_id = ?", originalAuthorID). 1113 1113 And(migratedIssueCond(tp)). 1114 - Update(map[string]interface{}{ 1114 + Update(map[string]any{ 1115 1115 "reviewer_id": posterID, 1116 1116 "original_author": "", 1117 1117 "original_author_id": 0,
+2 -2
models/migrations/base/db.go
··· 27 27 28 28 // RecreateTables will recreate the tables for the provided beans using the newly provided bean definition and move all data to that new table 29 29 // WARNING: YOU MUST PROVIDE THE FULL BEAN DEFINITION 30 - func RecreateTables(beans ...interface{}) func(*xorm.Engine) error { 30 + func RecreateTables(beans ...any) func(*xorm.Engine) error { 31 31 return func(x *xorm.Engine) error { 32 32 sess := x.NewSession() 33 33 defer sess.Close() ··· 48 48 // RecreateTable will recreate the table using the newly provided bean definition and move all data to that new table 49 49 // WARNING: YOU MUST PROVIDE THE FULL BEAN DEFINITION 50 50 // WARNING: YOU MUST COMMIT THE SESSION AT THE END 51 - func RecreateTable(sess *xorm.Session, bean interface{}) error { 51 + func RecreateTable(sess *xorm.Session, bean any) error { 52 52 // TODO: This will not work if there are foreign keys 53 53 54 54 tableName := sess.Engine().TableName(bean)
+1 -1
models/migrations/base/tests.go
··· 30 30 // Provide models to be sync'd with the database - in particular any models you expect fixtures to be loaded from. 31 31 // 32 32 // fixtures in `models/migrations/fixtures/<TestName>` will be loaded automatically 33 - func PrepareTestEnv(t *testing.T, skip int, syncModels ...interface{}) (*xorm.Engine, func()) { 33 + func PrepareTestEnv(t *testing.T, skip int, syncModels ...any) (*xorm.Engine, func()) { 34 34 t.Helper() 35 35 ourSkip := 2 36 36 ourSkip += skip
+5 -5
models/migrations/v1_10/v100.go
··· 59 59 } 60 60 61 61 type ExternalLoginUser struct { 62 - ExternalID string `xorm:"pk NOT NULL"` 63 - UserID int64 `xorm:"INDEX NOT NULL"` 64 - LoginSourceID int64 `xorm:"pk NOT NULL"` 65 - RawData map[string]interface{} `xorm:"TEXT JSON"` 66 - Provider string `xorm:"index VARCHAR(25)"` 62 + ExternalID string `xorm:"pk NOT NULL"` 63 + UserID int64 `xorm:"INDEX NOT NULL"` 64 + LoginSourceID int64 `xorm:"pk NOT NULL"` 65 + RawData map[string]any `xorm:"TEXT JSON"` 66 + Provider string `xorm:"index VARCHAR(25)"` 67 67 Email string 68 68 Name string 69 69 FirstName string
+3 -3
models/migrations/v1_16/v189.go
··· 14 14 ) 15 15 16 16 func UnwrapLDAPSourceCfg(x *xorm.Engine) error { 17 - jsonUnmarshalHandleDoubleEncode := func(bs []byte, v interface{}) error { 17 + jsonUnmarshalHandleDoubleEncode := func(bs []byte, v any) error { 18 18 err := json.Unmarshal(bs, v) 19 19 if err != nil { 20 20 ok := true ··· 54 54 const dldapType = 5 55 55 56 56 type WrappedSource struct { 57 - Source map[string]interface{} 57 + Source map[string]any 58 58 } 59 59 60 60 // change lower_email as unique ··· 77 77 78 78 for _, source := range sources { 79 79 wrapped := &WrappedSource{ 80 - Source: map[string]interface{}{}, 80 + Source: map[string]any{}, 81 81 } 82 82 err := jsonUnmarshalHandleDoubleEncode([]byte(source.Cfg), &wrapped) 83 83 if err != nil {
+2 -2
models/migrations/v1_16/v189_test.go
··· 62 62 } 63 63 64 64 for _, source := range sources { 65 - converted := map[string]interface{}{} 66 - expected := map[string]interface{}{} 65 + converted := map[string]any{} 66 + expected := map[string]any{} 67 67 68 68 if err := json.Unmarshal([]byte(source.Cfg), &converted); err != nil { 69 69 assert.NoError(t, err)
+1 -1
models/migrations/v1_19/v233_test.go
··· 79 79 return 80 80 } 81 81 for _, h := range hookTasks { 82 - var m map[string]interface{} 82 + var m map[string]any 83 83 err := json.Unmarshal([]byte(h.PayloadContent), &m) 84 84 assert.NoError(t, err) 85 85 assert.Nil(t, m["access_token"])
+6 -6
models/migrations/v1_6/v70.go
··· 81 81 // RepoUnit describes all units of a repository 82 82 type RepoUnit struct { 83 83 ID int64 84 - RepoID int64 `xorm:"INDEX(s)"` 85 - Type int `xorm:"INDEX(s)"` 86 - Config map[string]interface{} `xorm:"JSON"` 87 - CreatedUnix int64 `xorm:"INDEX CREATED"` 88 - Created time.Time `xorm:"-"` 84 + RepoID int64 `xorm:"INDEX(s)"` 85 + Type int `xorm:"INDEX(s)"` 86 + Config map[string]any `xorm:"JSON"` 87 + CreatedUnix int64 `xorm:"INDEX CREATED"` 88 + Created time.Time `xorm:"-"` 89 89 } 90 90 91 91 // Updating existing issue units ··· 96 96 } 97 97 for _, unit := range units { 98 98 if unit.Config == nil { 99 - unit.Config = make(map[string]interface{}) 99 + unit.Config = make(map[string]any) 100 100 } 101 101 if _, ok := unit.Config["EnableDependencies"]; !ok { 102 102 unit.Config["EnableDependencies"] = setting.Service.DefaultEnableDependencies
+5 -5
models/migrations/v1_8/v76.go
··· 15 15 // RepoUnit describes all units of a repository 16 16 type RepoUnit struct { 17 17 ID int64 18 - RepoID int64 `xorm:"INDEX(s)"` 19 - Type int `xorm:"INDEX(s)"` 20 - Config map[string]interface{} `xorm:"JSON"` 21 - CreatedUnix timeutil.TimeStamp `xorm:"INDEX CREATED"` 18 + RepoID int64 `xorm:"INDEX(s)"` 19 + Type int `xorm:"INDEX(s)"` 20 + Config map[string]any `xorm:"JSON"` 21 + CreatedUnix timeutil.TimeStamp `xorm:"INDEX CREATED"` 22 22 } 23 23 24 24 const ( ··· 46 46 } 47 47 for _, unit := range units { 48 48 if unit.Config == nil { 49 - unit.Config = make(map[string]interface{}) 49 + unit.Config = make(map[string]any) 50 50 } 51 51 // Allow the new merge style if all other merge styles are allowed 52 52 allowMergeRebase := true
+2 -2
models/packages/descriptor.go
··· 59 59 Creator *user_model.User 60 60 PackageProperties PackagePropertyList 61 61 VersionProperties PackagePropertyList 62 - Metadata interface{} 62 + Metadata any 63 63 Files []*PackageFileDescriptor 64 64 } 65 65 ··· 136 136 return nil, err 137 137 } 138 138 139 - var metadata interface{} 139 + var metadata any 140 140 switch p.Type { 141 141 case TypeAlpine: 142 142 metadata = &alpine.VersionMetadata{}
+1 -1
models/repo.go
··· 456 456 return repo_model.UpdateRepoIssueNumbers(ctx, id, true, true) 457 457 } 458 458 459 - func statsQuery(args ...interface{}) func(context.Context) ([]map[string][]byte, error) { 459 + func statsQuery(args ...any) func(context.Context) ([]map[string][]byte, error) { 460 460 return func(ctx context.Context) ([]map[string][]byte, error) { 461 461 return db.GetEngine(ctx).Query(args...) 462 462 }
+1 -1
models/repo/mirror.go
··· 105 105 } 106 106 107 107 // MirrorsIterate iterates all mirror repositories. 108 - func MirrorsIterate(limit int, f func(idx int, bean interface{}) error) error { 108 + func MirrorsIterate(limit int, f func(idx int, bean any) error) error { 109 109 sess := db.GetEngine(db.DefaultContext). 110 110 Where("next_update_unix<=?", time.Now().Unix()). 111 111 And("next_update_unix!=0").
+1 -1
models/repo/pushmirror.go
··· 127 127 } 128 128 129 129 // PushMirrorsIterate iterates all push-mirror repositories. 130 - func PushMirrorsIterate(ctx context.Context, limit int, f func(idx int, bean interface{}) error) error { 130 + func PushMirrorsIterate(ctx context.Context, limit int, f func(idx int, bean any) error) error { 131 131 sess := db.GetEngine(ctx). 132 132 Where("last_update + (`interval` / ?) <= ?", time.Second, time.Now().Unix()). 133 133 And("`interval` != 0").
+1 -1
models/repo/pushmirror_test.go
··· 41 41 42 42 time.Sleep(1 * time.Millisecond) 43 43 44 - repo_model.PushMirrorsIterate(db.DefaultContext, 1, func(idx int, bean interface{}) error { 44 + repo_model.PushMirrorsIterate(db.DefaultContext, 1, func(idx int, bean any) error { 45 45 m, ok := bean.(*repo_model.PushMirror) 46 46 assert.True(t, ok) 47 47 assert.Equal(t, "test-1", m.RemoteName)
+1 -1
models/repo/release.go
··· 442 442 _, err := db.GetEngine(db.DefaultContext).Table("release"). 443 443 Where("repo_id IN (SELECT id FROM repository WHERE original_service_type = ?)", gitServiceType). 444 444 And("original_author_id = ?", originalAuthorID). 445 - Update(map[string]interface{}{ 445 + Update(map[string]any{ 446 446 "publisher_id": posterID, 447 447 "original_author": "", 448 448 "original_author_id": 0,
+1 -1
models/repo/repo_list.go
··· 560 560 opts.OrderBy = db.SearchOrderByAlphabetically 561 561 } 562 562 563 - args := make([]interface{}, 0) 563 + args := make([]any, 0) 564 564 if opts.PriorityOwnerID > 0 { 565 565 opts.OrderBy = db.SearchOrderBy(fmt.Sprintf("CASE WHEN owner_id = ? THEN 0 ELSE owner_id END, %s", opts.OrderBy)) 566 566 args = append(args, opts.PriorityOwnerID)
+2 -2
models/system/notice.go
··· 43 43 } 44 44 45 45 // CreateNotice creates new system notice. 46 - func CreateNotice(ctx context.Context, tp NoticeType, desc string, args ...interface{}) error { 46 + func CreateNotice(ctx context.Context, tp NoticeType, desc string, args ...any) error { 47 47 if len(args) > 0 { 48 48 desc = fmt.Sprintf(desc, args...) 49 49 } ··· 55 55 } 56 56 57 57 // CreateRepositoryNotice creates new system notice with type NoticeRepository. 58 - func CreateRepositoryNotice(desc string, args ...interface{}) error { 58 + func CreateRepositoryNotice(desc string, args ...any) error { 59 59 // Note we use the db.DefaultContext here rather than passing in a context as the context may be cancelled 60 60 return CreateNotice(db.DefaultContext, NoticeRepository, desc, args...) 61 61 }
+11 -11
models/unittest/consistency.go
··· 21 21 modelsCommentTypeComment = 0 22 22 ) 23 23 24 - var consistencyCheckMap = make(map[string]func(t assert.TestingT, bean interface{})) 24 + var consistencyCheckMap = make(map[string]func(t assert.TestingT, bean any)) 25 25 26 26 // CheckConsistencyFor test that all matching database entries are consistent 27 - func CheckConsistencyFor(t assert.TestingT, beansToCheck ...interface{}) { 27 + func CheckConsistencyFor(t assert.TestingT, beansToCheck ...any) { 28 28 for _, bean := range beansToCheck { 29 29 sliceType := reflect.SliceOf(reflect.TypeOf(bean)) 30 30 sliceValue := reflect.MakeSlice(sliceType, 0, 10) ··· 42 42 } 43 43 } 44 44 45 - func checkForConsistency(t assert.TestingT, bean interface{}) { 45 + func checkForConsistency(t assert.TestingT, bean any) { 46 46 tb, err := db.TableInfo(bean) 47 47 assert.NoError(t, err) 48 48 f := consistencyCheckMap[tb.Name] ··· 63 63 return i 64 64 } 65 65 66 - checkForUserConsistency := func(t assert.TestingT, bean interface{}) { 66 + checkForUserConsistency := func(t assert.TestingT, bean any) { 67 67 user := reflectionWrap(bean) 68 68 AssertCountByCond(t, "repository", builder.Eq{"owner_id": user.int("ID")}, user.int("NumRepos")) 69 69 AssertCountByCond(t, "star", builder.Eq{"uid": user.int("ID")}, user.int("NumStars")) ··· 77 77 } 78 78 } 79 79 80 - checkForRepoConsistency := func(t assert.TestingT, bean interface{}) { 80 + checkForRepoConsistency := func(t assert.TestingT, bean any) { 81 81 repo := reflectionWrap(bean) 82 82 assert.Equal(t, repo.str("LowerName"), strings.ToLower(repo.str("Name")), "repo: %+v", repo) 83 83 AssertCountByCond(t, "star", builder.Eq{"repo_id": repo.int("ID")}, repo.int("NumStars")) ··· 113 113 "Unexpected number of closed milestones for repo id: %d", repo.int("ID")) 114 114 } 115 115 116 - checkForIssueConsistency := func(t assert.TestingT, bean interface{}) { 116 + checkForIssueConsistency := func(t assert.TestingT, bean any) { 117 117 issue := reflectionWrap(bean) 118 118 typeComment := modelsCommentTypeComment 119 119 actual := GetCountByCond(t, "comment", builder.Eq{"`type`": typeComment, "issue_id": issue.int("ID")}) ··· 124 124 } 125 125 } 126 126 127 - checkForPullRequestConsistency := func(t assert.TestingT, bean interface{}) { 127 + checkForPullRequestConsistency := func(t assert.TestingT, bean any) { 128 128 pr := reflectionWrap(bean) 129 129 issueRow := AssertExistsAndLoadMap(t, "issue", builder.Eq{"id": pr.int("IssueID")}) 130 130 assert.True(t, parseBool(issueRow["is_pull"])) 131 131 assert.EqualValues(t, parseInt(issueRow["index"]), pr.int("Index"), "Unexpected index for pull request id: %d", pr.int("ID")) 132 132 } 133 133 134 - checkForMilestoneConsistency := func(t assert.TestingT, bean interface{}) { 134 + checkForMilestoneConsistency := func(t assert.TestingT, bean any) { 135 135 milestone := reflectionWrap(bean) 136 136 AssertCountByCond(t, "issue", builder.Eq{"milestone_id": milestone.int("ID")}, milestone.int("NumIssues")) 137 137 ··· 145 145 assert.Equal(t, completeness, milestone.int("Completeness")) 146 146 } 147 147 148 - checkForLabelConsistency := func(t assert.TestingT, bean interface{}) { 148 + checkForLabelConsistency := func(t assert.TestingT, bean any) { 149 149 label := reflectionWrap(bean) 150 150 issueLabels, err := db.GetEngine(db.DefaultContext).Table("issue_label"). 151 151 Where(builder.Eq{"label_id": label.int("ID")}). ··· 166 166 assert.EqualValues(t, expected, label.int("NumClosedIssues"), "Unexpected number of closed issues for label id: %d", label.int("ID")) 167 167 } 168 168 169 - checkForTeamConsistency := func(t assert.TestingT, bean interface{}) { 169 + checkForTeamConsistency := func(t assert.TestingT, bean any) { 170 170 team := reflectionWrap(bean) 171 171 AssertCountByCond(t, "team_user", builder.Eq{"team_id": team.int("ID")}, team.int("NumMembers")) 172 172 AssertCountByCond(t, "team_repo", builder.Eq{"team_id": team.int("ID")}, team.int("NumRepos")) 173 173 } 174 174 175 - checkForActionConsistency := func(t assert.TestingT, bean interface{}) { 175 + checkForActionConsistency := func(t assert.TestingT, bean any) { 176 176 action := reflectionWrap(bean) 177 177 if action.int("RepoID") != 1700 { // dangling intentional 178 178 repoRow := AssertExistsAndLoadMap(t, "repository", builder.Eq{"id": action.int("RepoID")})
+1 -1
models/unittest/reflection.go
··· 23 23 v reflect.Value 24 24 } 25 25 26 - func reflectionWrap(v interface{}) *reflectionValue { 26 + func reflectionWrap(v any) *reflectionValue { 27 27 return &reflectionValue{v: reflect.ValueOf(v)} 28 28 } 29 29
+1 -1
models/unittest/testdb.go
··· 37 37 return fixturesDir 38 38 } 39 39 40 - func fatalTestError(fmtStr string, args ...interface{}) { 40 + func fatalTestError(fmtStr string, args ...any) { 41 41 _, _ = fmt.Fprintf(os.Stderr, fmtStr, args...) 42 42 os.Exit(1) 43 43 }
+5 -5
models/user/external_login_user.go
··· 57 57 58 58 // ExternalLoginUser makes the connecting between some existing user and additional external login sources 59 59 type ExternalLoginUser struct { 60 - ExternalID string `xorm:"pk NOT NULL"` 61 - UserID int64 `xorm:"INDEX NOT NULL"` 62 - LoginSourceID int64 `xorm:"pk NOT NULL"` 63 - RawData map[string]interface{} `xorm:"TEXT JSON"` 64 - Provider string `xorm:"index VARCHAR(25)"` 60 + ExternalID string `xorm:"pk NOT NULL"` 61 + UserID int64 `xorm:"INDEX NOT NULL"` 62 + LoginSourceID int64 `xorm:"pk NOT NULL"` 63 + RawData map[string]any `xorm:"TEXT JSON"` 64 + Provider string `xorm:"index VARCHAR(25)"` 65 65 Email string 66 66 Name string 67 67 FirstName string
+1 -1
models/webhook/hooktask.go
··· 92 92 } 93 93 } 94 94 95 - func (t *HookTask) simpleMarshalJSON(v interface{}) string { 95 + func (t *HookTask) simpleMarshalJSON(v any) string { 96 96 p, err := json.Marshal(v) 97 97 if err != nil { 98 98 log.Error("Marshal [%d]: %v", t.ID, err)
+1 -1
modules/actions/workflows.go
··· 29 29 } 30 30 31 31 func init() { 32 - model.OnDecodeNodeError = func(node yaml.Node, out interface{}, err error) { 32 + model.OnDecodeNodeError = func(node yaml.Node, out any, err error) { 33 33 // Log the error instead of panic or fatal. 34 34 // It will be a big job to refactor act/pkg/model to return decode error, 35 35 // so we just log the error and return empty value, and improve it later.
+2 -2
modules/base/tool.go
··· 107 107 108 108 // CreateTimeLimitCode create a time limit code 109 109 // code format: 12 length date time string + 6 minutes string + 40 sha1 encoded string 110 - func CreateTimeLimitCode(data string, minutes int, startInf interface{}) string { 110 + func CreateTimeLimitCode(data string, minutes int, startInf any) string { 111 111 format := "200601021504" 112 112 113 113 var start, end time.Time ··· 245 245 } 246 246 247 247 // FormatNumberSI format a number 248 - func FormatNumberSI(data interface{}) string { 248 + func FormatNumberSI(data any) string { 249 249 var num int64 250 250 if num1, ok := data.(int64); ok { 251 251 num = num1
+3 -3
modules/cache/cache_redis.go
··· 24 24 } 25 25 26 26 // toStr convert string/int/int64 interface to string. it's only used by the RedisCacher.Put internally 27 - func toStr(v interface{}) string { 27 + func toStr(v any) string { 28 28 if v == nil { 29 29 return "" 30 30 } ··· 44 44 45 45 // Put puts value (string type) into cache with key and expire time. 46 46 // If expired is 0, it lives forever. 47 - func (c *RedisCacher) Put(key string, val interface{}, expire int64) error { 47 + func (c *RedisCacher) Put(key string, val any, expire int64) error { 48 48 // this function is not well-designed, it only puts string values into cache 49 49 key = c.prefix + key 50 50 if expire == 0 { ··· 65 65 } 66 66 67 67 // Get gets cached value by given key. 68 - func (c *RedisCacher) Get(key string) interface{} { 68 + func (c *RedisCacher) Get(key string) any { 69 69 val, err := c.c.Get(graceful.GetManager().HammerContext(), c.prefix+key).Result() 70 70 if err != nil { 71 71 return nil
+4 -4
modules/cache/cache_twoqueue.go
··· 30 30 31 31 // MemoryItem represents a memory cache item. 32 32 type MemoryItem struct { 33 - Val interface{} 33 + Val any 34 34 Created int64 35 35 Timeout int64 36 36 } ··· 43 43 var _ mc.Cache = &TwoQueueCache{} 44 44 45 45 // Put puts value into cache with key and expire time. 46 - func (c *TwoQueueCache) Put(key string, val interface{}, timeout int64) error { 46 + func (c *TwoQueueCache) Put(key string, val any, timeout int64) error { 47 47 item := &MemoryItem{ 48 48 Val: val, 49 49 Created: time.Now().Unix(), ··· 56 56 } 57 57 58 58 // Get gets cached value by given key. 59 - func (c *TwoQueueCache) Get(key string) interface{} { 59 + func (c *TwoQueueCache) Get(key string) any { 60 60 c.lock.Lock() 61 61 defer c.lock.Unlock() 62 62 cached, ok := c.cache.Get(key) ··· 146 146 return nil 147 147 } 148 148 149 - func (c *TwoQueueCache) checkAndInvalidate(key interface{}) { 149 + func (c *TwoQueueCache) checkAndInvalidate(key any) { 150 150 c.lock.Lock() 151 151 defer c.lock.Unlock() 152 152 cached, ok := c.cache.Peek(key)
+5 -5
modules/charset/ambiguous/generate.go
··· 90 90 sort.Slice(tables, func(i, j int) bool { 91 91 return tables[i].Locale < tables[j].Locale 92 92 }) 93 - data := map[string]interface{}{ 93 + data := map[string]any{ 94 94 "Tables": tables, 95 95 } 96 96 ··· 99 99 } 100 100 } 101 101 102 - func runTemplate(t *template.Template, filename string, data interface{}) error { 102 + func runTemplate(t *template.Template, filename string, data any) error { 103 103 buf := bytes.NewBuffer(nil) 104 104 if err := t.Execute(buf, data); err != nil { 105 105 return fmt.Errorf("unable to execute template: %w", err) ··· 172 172 173 173 `)) 174 174 175 - func logf(format string, args ...interface{}) { 175 + func logf(format string, args ...any) { 176 176 fmt.Fprintf(os.Stderr, format+"\n", args...) 177 177 } 178 178 179 - func verbosef(format string, args ...interface{}) { 179 + func verbosef(format string, args ...any) { 180 180 if verbose { 181 181 logf(format, args...) 182 182 } 183 183 } 184 184 185 - func fatalf(format string, args ...interface{}) { 185 + func fatalf(format string, args ...any) { 186 186 logf("fatal: "+format+"\n", args...) 187 187 os.Exit(1) 188 188 }
+4 -4
modules/charset/invisible/generate.go
··· 52 52 } 53 53 } 54 54 55 - func runTemplate(t *template.Template, filename string, data interface{}) error { 55 + func runTemplate(t *template.Template, filename string, data any) error { 56 56 buf := bytes.NewBuffer(nil) 57 57 if err := t.Execute(buf, data); err != nil { 58 58 return fmt.Errorf("unable to execute template: %w", err) ··· 105 105 } 106 106 `)) 107 107 108 - func logf(format string, args ...interface{}) { 108 + func logf(format string, args ...any) { 109 109 fmt.Fprintf(os.Stderr, format+"\n", args...) 110 110 } 111 111 112 - func verbosef(format string, args ...interface{}) { 112 + func verbosef(format string, args ...any) { 113 113 if verbose { 114 114 logf(format, args...) 115 115 } 116 116 } 117 117 118 - func fatalf(format string, args ...interface{}) { 118 + func fatalf(format string, args ...any) { 119 119 logf("fatal: "+format+"\n", args...) 120 120 os.Exit(1) 121 121 }
+2 -2
modules/context/access_log.go
··· 23 23 Identity *string 24 24 Start *time.Time 25 25 ResponseWriter http.ResponseWriter 26 - Ctx map[string]interface{} 26 + Ctx map[string]any 27 27 RequestID *string 28 28 } 29 29 ··· 84 84 Identity: &identity, 85 85 Start: &start, 86 86 ResponseWriter: rw, 87 - Ctx: map[string]interface{}{ 87 + Ctx: map[string]any{ 88 88 "RemoteAddr": req.RemoteAddr, 89 89 "RemoteHost": reqHost, 90 90 "Req": req,
+3 -3
modules/context/api.go
··· 108 108 109 109 // Error responds with an error message to client with given obj as the message. 110 110 // If status is 500, also it prints error to log. 111 - func (ctx *APIContext) Error(status int, title string, obj interface{}) { 111 + func (ctx *APIContext) Error(status int, title string, obj any) { 112 112 var message string 113 113 if err, ok := obj.(error); ok { 114 114 message = err.Error() ··· 265 265 266 266 // NotFound handles 404s for APIContext 267 267 // String will replace message, errors will be added to a slice 268 - func (ctx *APIContext) NotFound(objs ...interface{}) { 268 + func (ctx *APIContext) NotFound(objs ...any) { 269 269 message := ctx.Tr("error.not_found") 270 270 var errors []string 271 271 for _, obj := range objs { ··· 281 281 } 282 282 } 283 283 284 - ctx.JSON(http.StatusNotFound, map[string]interface{}{ 284 + ctx.JSON(http.StatusNotFound, map[string]any{ 285 285 "message": message, 286 286 "url": setting.API.SwaggerURL, 287 287 "errors": errors,
+1 -1
modules/context/base.go
··· 128 128 } 129 129 130 130 // JSON render content as JSON 131 - func (b *Base) JSON(status int, content interface{}) { 131 + func (b *Base) JSON(status int, content any) { 132 132 b.Resp.Header().Set("Content-Type", "application/json;charset=utf-8") 133 133 b.Resp.WriteHeader(status) 134 134 if err := json.NewEncoder(b.Resp).Encode(content); err != nil {
+1 -1
modules/context/captcha.go
··· 60 60 61 61 // VerifyCaptcha verifies Captcha data 62 62 // No-op if captchas are not enabled 63 - func VerifyCaptcha(ctx *Context, tpl base.TplName, form interface{}) { 63 + func VerifyCaptcha(ctx *Context, tpl base.TplName, form any) { 64 64 if !setting.Service.EnableCaptcha { 65 65 return 66 66 }
+2 -2
modules/context/context.go
··· 32 32 // Render represents a template render 33 33 type Render interface { 34 34 TemplateLookup(tmpl string) (templates.TemplateExecutor, error) 35 - HTML(w io.Writer, status int, name string, data interface{}) error 35 + HTML(w io.Writer, status int, name string, data any) error 36 36 } 37 37 38 38 // Context represents context of a request. ··· 69 69 // TrHTMLEscapeArgs runs ".Locale.Tr()" but pre-escapes all arguments with html.EscapeString. 70 70 // This is useful if the locale message is intended to only produce HTML content. 71 71 func (ctx *Context) TrHTMLEscapeArgs(msg string, args ...string) string { 72 - trArgs := make([]interface{}, len(args)) 72 + trArgs := make([]any, len(args)) 73 73 for i, arg := range args { 74 74 trArgs[i] = html.EscapeString(arg) 75 75 }
+2 -2
modules/context/context_response.go
··· 91 91 } 92 92 93 93 // RenderToString renders the template content to a string 94 - func (ctx *Context) RenderToString(name base.TplName, data map[string]interface{}) (string, error) { 94 + func (ctx *Context) RenderToString(name base.TplName, data map[string]any) (string, error) { 95 95 var buf strings.Builder 96 96 err := ctx.Render.HTML(&buf, http.StatusOK, string(name), data) 97 97 return buf.String(), err 98 98 } 99 99 100 100 // RenderWithErr used for page has form validation but need to prompt error to users. 101 - func (ctx *Context) RenderWithErr(msg string, tpl base.TplName, form interface{}) { 101 + func (ctx *Context) RenderWithErr(msg string, tpl base.TplName, form any) { 102 102 if form != nil { 103 103 middleware.AssignForm(form, ctx.Data) 104 104 }
+2 -2
modules/context/package.go
··· 33 33 // PackageAssignment returns a middleware to handle Context.Package assignment 34 34 func PackageAssignment() func(ctx *Context) { 35 35 return func(ctx *Context) { 36 - errorFn := func(status int, title string, obj interface{}) { 36 + errorFn := func(status int, title string, obj any) { 37 37 err, ok := obj.(error) 38 38 if !ok { 39 39 err = fmt.Errorf("%s", obj) ··· 57 57 } 58 58 } 59 59 60 - func packageAssignment(ctx *packageAssignmentCtx, errCb func(int, string, interface{})) *Package { 60 + func packageAssignment(ctx *packageAssignmentCtx, errCb func(int, string, any)) *Package { 61 61 pkg := &Package{ 62 62 Owner: ctx.ContextUser, 63 63 }
+1 -1
modules/context/pagination.go
··· 32 32 if !exists { 33 33 return 34 34 } 35 - paramData := fmt.Sprintf("%v", ctx.Data[ctxKey]) // cast interface{} to string 35 + paramData := fmt.Sprintf("%v", ctx.Data[ctxKey]) // cast any to string 36 36 urlParam := fmt.Sprintf("%s=%v", url.QueryEscape(paramKey), url.QueryEscape(paramData)) 37 37 p.urlParams = append(p.urlParams, urlParam) 38 38 }
+1 -1
modules/context/permission.go
··· 90 90 } 91 91 if log.IsTrace() { 92 92 var format string 93 - var args []interface{} 93 + var args []any 94 94 if ctx.IsSigned { 95 95 format = "Permission Denied: User %-v cannot read [" 96 96 args = append(args, ctx.Doer)
+1 -1
modules/context/private.go
··· 53 53 return ctx.Base.Err() 54 54 } 55 55 56 - var privateContextKey interface{} = "default_private_context" 56 + var privateContextKey any = "default_private_context" 57 57 58 58 // GetPrivateContext returns a context for Private routes 59 59 func GetPrivateContext(req *http.Request) *PrivateContext {
+2 -2
modules/eventsource/event.go
··· 51 51 type Event struct { 52 52 // Name represents the value of the event: tag in the stream 53 53 Name string 54 - // Data is either JSONified []byte or interface{} that can be JSONd 55 - Data interface{} 54 + // Data is either JSONified []byte or any that can be JSONd 55 + Data any 56 56 // ID represents the ID of an event 57 57 ID string 58 58 // Retry tells the receiver only to attempt to reconnect to the source after this time
+1 -1
modules/git/commit_info_gogit.go
··· 177 177 refSha := c.ID().String() 178 178 179 179 // We do a tree traversal with nodes sorted by commit time 180 - heap := binaryheap.NewWith(func(a, b interface{}) int { 180 + heap := binaryheap.NewWith(func(a, b any) int { 181 181 if a.(*commitAndPaths).commit.CommitTime().Before(b.(*commitAndPaths).commit.CommitTime()) { 182 182 return 1 183 183 }
+1 -1
modules/git/foreachref/parser_test.go
··· 217 217 } 218 218 } 219 219 220 - func pretty(v interface{}) string { 220 + func pretty(v any) string { 221 221 data, err := json.MarshalIndent(v, "", " ") 222 222 if err != nil { 223 223 // shouldn't happen
+1 -1
modules/git/git.go
··· 114 114 return "(git not found)" 115 115 } 116 116 format := "%s" 117 - args := []interface{}{gitVersion.Original()} 117 + args := []any{gitVersion.Original()} 118 118 // Since git wire protocol has been released from git v2.18 119 119 if setting.Git.EnableAutoGitWireProtocol && CheckGitVersionAtLeast("2.18") == nil { 120 120 format += ", Wire Protocol %s Enabled"
+2 -2
modules/git/last_commit_cache.go
··· 15 15 // Cache represents a caching interface 16 16 type Cache interface { 17 17 // Put puts value into cache with key and expire time. 18 - Put(key string, val interface{}, timeout int64) error 18 + Put(key string, val any, timeout int64) error 19 19 // Get gets cached value by given key. 20 - Get(key string) interface{} 20 + Get(key string) any 21 21 } 22 22 23 23 func getCacheKey(repoPath, commitID, entryPath string) string {
+4 -4
modules/git/utils.go
··· 15 15 // ObjectCache provides thread-safe cache operations. 16 16 type ObjectCache struct { 17 17 lock sync.RWMutex 18 - cache map[string]interface{} 18 + cache map[string]any 19 19 } 20 20 21 21 func newObjectCache() *ObjectCache { 22 22 return &ObjectCache{ 23 - cache: make(map[string]interface{}, 10), 23 + cache: make(map[string]any, 10), 24 24 } 25 25 } 26 26 27 27 // Set add obj to cache 28 - func (oc *ObjectCache) Set(id string, obj interface{}) { 28 + func (oc *ObjectCache) Set(id string, obj any) { 29 29 oc.lock.Lock() 30 30 defer oc.lock.Unlock() 31 31 ··· 33 33 } 34 34 35 35 // Get get cached obj by id 36 - func (oc *ObjectCache) Get(id string) (interface{}, bool) { 36 + func (oc *ObjectCache) Get(id string) (any, bool) { 37 37 oc.lock.RLock() 38 38 defer oc.lock.RUnlock() 39 39
+1 -1
modules/graceful/manager.go
··· 283 283 } 284 284 285 285 // Value allows the manager to be viewed as a context.Context done at Terminate 286 - func (g *Manager) Value(key interface{}) interface{} { 286 + func (g *Manager) Value(key any) any { 287 287 return g.managerCtx.Value(key) 288 288 } 289 289
+1 -1
modules/html/html.go
··· 5 5 6 6 // ParseSizeAndClass get size and class from string with default values 7 7 // If present, "others" expects the new size first and then the classes to use 8 - func ParseSizeAndClass(defaultSize int, defaultClass string, others ...interface{}) (int, string) { 8 + func ParseSizeAndClass(defaultSize int, defaultClass string, others ...any) (int, string) { 9 9 if len(others) == 0 { 10 10 return defaultSize, defaultClass 11 11 }
+1 -1
modules/httplib/request.go
··· 101 101 102 102 // Body adds request raw body. 103 103 // it supports string and []byte. 104 - func (r *Request) Body(data interface{}) *Request { 104 + func (r *Request) Body(data any) *Request { 105 105 switch t := data.(type) { 106 106 case string: 107 107 bf := bytes.NewBufferString(t)
+2 -2
modules/indexer/code/bleve/bleve.go
··· 51 51 } 52 52 53 53 func addUnicodeNormalizeTokenFilter(m *mapping.IndexMappingImpl) error { 54 - return m.AddCustomTokenFilter(unicodeNormalizeName, map[string]interface{}{ 54 + return m.AddCustomTokenFilter(unicodeNormalizeName, map[string]any{ 55 55 "type": unicodenorm.Name, 56 56 "form": unicodenorm.NFC, 57 57 }) ··· 101 101 mapping := bleve.NewIndexMapping() 102 102 if err := addUnicodeNormalizeTokenFilter(mapping); err != nil { 103 103 return nil, err 104 - } else if err := mapping.AddCustomAnalyzer(repoIndexerAnalyzer, map[string]interface{}{ 104 + } else if err := mapping.AddCustomAnalyzer(repoIndexerAnalyzer, map[string]any{ 105 105 "type": analyzer_custom.Name, 106 106 "char_filters": []string{}, 107 107 "tokenizer": unicode.Name,
+3 -3
modules/indexer/code/elasticsearch/elasticsearch.go
··· 133 133 elastic.NewBulkIndexRequest(). 134 134 Index(b.inner.VersionedIndexName()). 135 135 Id(id). 136 - Doc(map[string]interface{}{ 136 + Doc(map[string]any{ 137 137 "repo_id": repo.ID, 138 138 "content": string(charset.ToUTF8DropErrors(fileContents)), 139 139 "commit_id": sha, ··· 234 234 } 235 235 236 236 repoID, fileName := internal.ParseIndexerID(hit.Id) 237 - res := make(map[string]interface{}) 237 + res := make(map[string]any) 238 238 if err := json.Unmarshal(hit.Source, &res); err != nil { 239 239 return 0, nil, nil, err 240 240 } ··· 285 285 query := elastic.NewBoolQuery() 286 286 query = query.Must(kwQuery) 287 287 if len(repoIDs) > 0 { 288 - repoStrs := make([]interface{}, 0, len(repoIDs)) 288 + repoStrs := make([]any, 0, len(repoIDs)) 289 289 for _, repoID := range repoIDs { 290 290 repoStrs = append(repoStrs, repoID) 291 291 }
+1 -1
modules/indexer/internal/bleve/batch.go
··· 27 27 } 28 28 29 29 // Index add a new index to batch 30 - func (b *FlushingBatch) Index(id string, data interface{}) error { 30 + func (b *FlushingBatch) Index(id string, data any) error { 31 31 if err := b.batch.Index(id, data); err != nil { 32 32 return err 33 33 }
+2 -2
modules/indexer/issues/bleve/bleve.go
··· 45 45 const unicodeNormalizeName = "unicodeNormalize" 46 46 47 47 func addUnicodeNormalizeTokenFilter(m *mapping.IndexMappingImpl) error { 48 - return m.AddCustomTokenFilter(unicodeNormalizeName, map[string]interface{}{ 48 + return m.AddCustomTokenFilter(unicodeNormalizeName, map[string]any{ 49 49 "type": unicodenorm.Name, 50 50 "form": unicodenorm.NFC, 51 51 }) ··· 80 80 81 81 if err := addUnicodeNormalizeTokenFilter(mapping); err != nil { 82 82 return nil, err 83 - } else if err = mapping.AddCustomAnalyzer(issueIndexerAnalyzer, map[string]interface{}{ 83 + } else if err = mapping.AddCustomAnalyzer(issueIndexerAnalyzer, map[string]any{ 84 84 "type": custom.Name, 85 85 "char_filters": []string{}, 86 86 "tokenizer": unicode.Name,
+3 -3
modules/indexer/issues/elasticsearch/elasticsearch.go
··· 76 76 _, err := b.inner.Client.Index(). 77 77 Index(b.inner.VersionedIndexName()). 78 78 Id(fmt.Sprintf("%d", issue.ID)). 79 - BodyJson(map[string]interface{}{ 79 + BodyJson(map[string]any{ 80 80 "id": issue.ID, 81 81 "repo_id": issue.RepoID, 82 82 "title": issue.Title, ··· 93 93 elastic.NewBulkIndexRequest(). 94 94 Index(b.inner.VersionedIndexName()). 95 95 Id(fmt.Sprintf("%d", issue.ID)). 96 - Doc(map[string]interface{}{ 96 + Doc(map[string]any{ 97 97 "id": issue.ID, 98 98 "repo_id": issue.RepoID, 99 99 "title": issue.Title, ··· 145 145 query := elastic.NewBoolQuery() 146 146 query = query.Must(kwQuery) 147 147 if len(repoIDs) > 0 { 148 - repoStrs := make([]interface{}, 0, len(repoIDs)) 148 + repoStrs := make([]any, 0, len(repoIDs)) 149 149 for _, repoID := range repoIDs { 150 150 repoStrs = append(repoStrs, repoID) 151 151 }
+1 -1
modules/indexer/issues/meilisearch/meilisearch.go
··· 88 88 hits := make([]internal.Match, 0, len(searchRes.Hits)) 89 89 for _, hit := range searchRes.Hits { 90 90 hits = append(hits, internal.Match{ 91 - ID: int64(hit.(map[string]interface{})["id"].(float64)), 91 + ID: int64(hit.(map[string]any)["id"].(float64)), 92 92 }) 93 93 } 94 94 return &internal.SearchResult{
+8 -8
modules/issue/template/template.go
··· 151 151 } 152 152 position := newErrorPosition(idx, field.Type) 153 153 154 - options, ok := field.Attributes["options"].([]interface{}) 154 + options, ok := field.Attributes["options"].([]any) 155 155 if !ok || len(options) == 0 { 156 156 return position.Errorf("'options' is required and should be a array") 157 157 } ··· 164 164 return position.Errorf("should be a string") 165 165 } 166 166 case api.IssueFormFieldTypeCheckboxes: 167 - opt, ok := option.(map[string]interface{}) 167 + opt, ok := option.(map[string]any) 168 168 if !ok { 169 169 return position.Errorf("should be a dictionary") 170 170 } ··· 182 182 return nil 183 183 } 184 184 185 - func validateStringItem(position errorPosition, m map[string]interface{}, required bool, names ...string) error { 185 + func validateStringItem(position errorPosition, m map[string]any, required bool, names ...string) error { 186 186 for _, name := range names { 187 187 v, ok := m[name] 188 188 if !ok { ··· 202 202 return nil 203 203 } 204 204 205 - func validateBoolItem(position errorPosition, m map[string]interface{}, names ...string) error { 205 + func validateBoolItem(position errorPosition, m map[string]any, names ...string) error { 206 206 for _, name := range names { 207 207 v, ok := m[name] 208 208 if !ok { ··· 217 217 218 218 type errorPosition string 219 219 220 - func (p errorPosition) Errorf(format string, a ...interface{}) error { 220 + func (p errorPosition) Errorf(format string, a ...any) error { 221 221 return fmt.Errorf(string(p)+": "+format, a...) 222 222 } 223 223 ··· 332 332 } 333 333 334 334 func (f *valuedField) Options() []*valuedOption { 335 - if options, ok := f.Attributes["options"].([]interface{}); ok { 335 + if options, ok := f.Attributes["options"].([]any); ok { 336 336 ret := make([]*valuedOption, 0, len(options)) 337 337 for i, option := range options { 338 338 ret = append(ret, &valuedOption{ ··· 348 348 349 349 type valuedOption struct { 350 350 index int 351 - data interface{} 351 + data any 352 352 field *valuedField 353 353 } 354 354 ··· 359 359 return label 360 360 } 361 361 case api.IssueFormFieldTypeCheckboxes: 362 - if vs, ok := o.data.(map[string]interface{}); ok { 362 + if vs, ok := o.data.(map[string]any); ok { 363 363 if v, ok := vs["label"].(string); ok { 364 364 return v 365 365 }
+16 -16
modules/issue/template/template_test.go
··· 387 387 { 388 388 Type: "markdown", 389 389 ID: "id1", 390 - Attributes: map[string]interface{}{ 390 + Attributes: map[string]any{ 391 391 "value": "Value of the markdown", 392 392 }, 393 393 }, 394 394 { 395 395 Type: "textarea", 396 396 ID: "id2", 397 - Attributes: map[string]interface{}{ 397 + Attributes: map[string]any{ 398 398 "label": "Label of textarea", 399 399 "description": "Description of textarea", 400 400 "placeholder": "Placeholder of textarea", 401 401 "value": "Value of textarea", 402 402 "render": "bash", 403 403 }, 404 - Validations: map[string]interface{}{ 404 + Validations: map[string]any{ 405 405 "required": true, 406 406 }, 407 407 }, 408 408 { 409 409 Type: "input", 410 410 ID: "id3", 411 - Attributes: map[string]interface{}{ 411 + Attributes: map[string]any{ 412 412 "label": "Label of input", 413 413 "description": "Description of input", 414 414 "placeholder": "Placeholder of input", 415 415 "value": "Value of input", 416 416 }, 417 - Validations: map[string]interface{}{ 417 + Validations: map[string]any{ 418 418 "required": true, 419 419 "is_number": true, 420 420 "regex": "[a-zA-Z0-9]+", ··· 423 423 { 424 424 Type: "dropdown", 425 425 ID: "id4", 426 - Attributes: map[string]interface{}{ 426 + Attributes: map[string]any{ 427 427 "label": "Label of dropdown", 428 428 "description": "Description of dropdown", 429 429 "multiple": true, 430 - "options": []interface{}{ 430 + "options": []any{ 431 431 "Option 1 of dropdown", 432 432 "Option 2 of dropdown", 433 433 "Option 3 of dropdown", 434 434 }, 435 435 }, 436 - Validations: map[string]interface{}{ 436 + Validations: map[string]any{ 437 437 "required": true, 438 438 }, 439 439 }, 440 440 { 441 441 Type: "checkboxes", 442 442 ID: "id5", 443 - Attributes: map[string]interface{}{ 443 + Attributes: map[string]any{ 444 444 "label": "Label of checkboxes", 445 445 "description": "Description of checkboxes", 446 - "options": []interface{}{ 447 - map[string]interface{}{"label": "Option 1 of checkboxes", "required": true}, 448 - map[string]interface{}{"label": "Option 2 of checkboxes", "required": false}, 449 - map[string]interface{}{"label": "Option 3 of checkboxes", "required": true}, 446 + "options": []any{ 447 + map[string]any{"label": "Option 1 of checkboxes", "required": true}, 448 + map[string]any{"label": "Option 2 of checkboxes", "required": false}, 449 + map[string]any{"label": "Option 3 of checkboxes", "required": true}, 450 450 }, 451 451 }, 452 452 }, ··· 479 479 { 480 480 Type: "markdown", 481 481 ID: "id1", 482 - Attributes: map[string]interface{}{ 482 + Attributes: map[string]any{ 483 483 "value": "Value of the markdown", 484 484 }, 485 485 }, ··· 512 512 { 513 513 Type: "markdown", 514 514 ID: "id1", 515 - Attributes: map[string]interface{}{ 515 + Attributes: map[string]any{ 516 516 "value": "Value of the markdown", 517 517 }, 518 518 }, ··· 545 545 { 546 546 Type: "markdown", 547 547 ID: "id1", 548 - Attributes: map[string]interface{}{ 548 + Attributes: map[string]any{ 549 549 "value": "Value of the markdown", 550 550 }, 551 551 },
+12 -12
modules/json/json.go
··· 15 15 16 16 // Encoder represents an encoder for json 17 17 type Encoder interface { 18 - Encode(v interface{}) error 18 + Encode(v any) error 19 19 } 20 20 21 21 // Decoder represents a decoder for json 22 22 type Decoder interface { 23 - Decode(v interface{}) error 23 + Decode(v any) error 24 24 } 25 25 26 26 // Interface represents an interface to handle json data 27 27 type Interface interface { 28 - Marshal(v interface{}) ([]byte, error) 29 - Unmarshal(data []byte, v interface{}) error 28 + Marshal(v any) ([]byte, error) 29 + Unmarshal(data []byte, v any) error 30 30 NewEncoder(writer io.Writer) Encoder 31 31 NewDecoder(reader io.Reader) Decoder 32 32 Indent(dst *bytes.Buffer, src []byte, prefix, indent string) error ··· 44 44 type StdJSON struct{} 45 45 46 46 // Marshal implements Interface 47 - func (StdJSON) Marshal(v interface{}) ([]byte, error) { 47 + func (StdJSON) Marshal(v any) ([]byte, error) { 48 48 return json.Marshal(v) 49 49 } 50 50 51 51 // Unmarshal implements Interface 52 - func (StdJSON) Unmarshal(data []byte, v interface{}) error { 52 + func (StdJSON) Unmarshal(data []byte, v any) error { 53 53 return json.Unmarshal(data, v) 54 54 } 55 55 ··· 74 74 } 75 75 76 76 // Marshal implements Interface 77 - func (j JSONiter) Marshal(v interface{}) ([]byte, error) { 77 + func (j JSONiter) Marshal(v any) ([]byte, error) { 78 78 return j.API.Marshal(v) 79 79 } 80 80 81 81 // Unmarshal implements Interface 82 - func (j JSONiter) Unmarshal(data []byte, v interface{}) error { 82 + func (j JSONiter) Unmarshal(data []byte, v any) error { 83 83 return j.API.Unmarshal(data, v) 84 84 } 85 85 ··· 99 99 } 100 100 101 101 // Marshal converts object as bytes 102 - func Marshal(v interface{}) ([]byte, error) { 102 + func Marshal(v any) ([]byte, error) { 103 103 return DefaultJSONHandler.Marshal(v) 104 104 } 105 105 106 106 // Unmarshal decodes object from bytes 107 - func Unmarshal(data []byte, v interface{}) error { 107 + func Unmarshal(data []byte, v any) error { 108 108 return DefaultJSONHandler.Unmarshal(data, v) 109 109 } 110 110 ··· 124 124 } 125 125 126 126 // MarshalIndent copied from encoding/json 127 - func MarshalIndent(v interface{}, prefix, indent string) ([]byte, error) { 127 + func MarshalIndent(v any, prefix, indent string) ([]byte, error) { 128 128 b, err := Marshal(v) 129 129 if err != nil { 130 130 return nil, err ··· 144 144 145 145 // UnmarshalHandleDoubleEncode - due to a bug in xorm (see https://gitea.com/xorm/xorm/pulls/1957) - it's 146 146 // possible that a Blob may be double encoded or gain an unwanted prefix of 0xff 0xfe. 147 - func UnmarshalHandleDoubleEncode(bs []byte, v interface{}) error { 147 + func UnmarshalHandleDoubleEncode(bs []byte, v any) error { 148 148 err := json.Unmarshal(bs, v) 149 149 if err != nil { 150 150 ok := true
+3 -3
modules/markup/html_internal_test.go
··· 120 120 isExternal = true 121 121 } 122 122 123 - links := make([]interface{}, len(indices)) 123 + links := make([]any, len(indices)) 124 124 for i, index := range indices { 125 125 links[i] = numericIssueLink(util.URLJoin(TestRepoURL, path), "ref-issue", index, marker) 126 126 } ··· 204 204 205 205 // alphanumeric: render inputs with valid mentions 206 206 test := func(s, expectedFmt string, names ...string) { 207 - links := make([]interface{}, len(names)) 207 + links := make([]any, len(names)) 208 208 for i, name := range names { 209 209 links[i] = externalIssueLink("https://someurl.com/someUser/someRepo/", "ref-issue ref-external-issue", name) 210 210 } ··· 226 226 test := func(s, expectedFmt, pattern string, ids, names []string) { 227 227 metas := regexpMetas 228 228 metas["regexp"] = pattern 229 - links := make([]interface{}, len(ids)) 229 + links := make([]any, len(ids)) 230 230 for i, id := range ids { 231 231 links[i] = link(util.URLJoin("https://someurl.com/someUser/someRepo/", id), "ref-issue ref-external-issue", names[i]) 232 232 }
+2 -2
modules/markup/markdown/meta.go
··· 55 55 56 56 // ExtractMetadata consumes a markdown file, parses YAML frontmatter, 57 57 // and returns the frontmatter metadata separated from the markdown content 58 - func ExtractMetadata(contents string, out interface{}) (string, error) { 58 + func ExtractMetadata(contents string, out any) (string, error) { 59 59 body, err := ExtractMetadataBytes([]byte(contents), out) 60 60 return string(body), err 61 61 } 62 62 63 63 // ExtractMetadata consumes a markdown file, parses YAML frontmatter, 64 64 // and returns the frontmatter metadata separated from the markdown content 65 - func ExtractMetadataBytes(contents []byte, out interface{}) ([]byte, error) { 65 + func ExtractMetadataBytes(contents []byte, out any) ([]byte, error) { 66 66 var front, body []byte 67 67 68 68 start, end := 0, len(contents)
+1 -1
modules/migration/comment.go
··· 24 24 Updated time.Time 25 25 Content string 26 26 Reactions []*Reaction 27 - Meta map[string]interface{} `yaml:"meta,omitempty"` // see models/issues/comment.go for fields in Comment struct 27 + Meta map[string]any `yaml:"meta,omitempty"` // see models/issues/comment.go for fields in Comment struct 28 28 } 29 29 30 30 // GetExternalName ExternalUserMigrated interface
+1 -1
modules/migration/downloader.go
··· 34 34 } 35 35 36 36 // DownloaderContext has opaque information only relevant to a given downloader 37 - type DownloaderContext interface{} 37 + type DownloaderContext any
+9 -9
modules/migration/file_format.go
··· 17 17 ) 18 18 19 19 // Load project data from file, with optional validation 20 - func Load(filename string, data interface{}, validation bool) error { 20 + func Load(filename string, data any, validation bool) error { 21 21 isJSON := strings.HasSuffix(filename, ".json") 22 22 23 23 bs, err := os.ReadFile(filename) ··· 34 34 return unmarshal(bs, data, isJSON) 35 35 } 36 36 37 - func unmarshal(bs []byte, data interface{}, isJSON bool) error { 37 + func unmarshal(bs []byte, data any, isJSON bool) error { 38 38 if isJSON { 39 39 return json.Unmarshal(bs, data) 40 40 } ··· 47 47 return c.Compile(filename) 48 48 } 49 49 50 - func validate(bs []byte, datatype interface{}, isJSON bool) error { 51 - var v interface{} 50 + func validate(bs []byte, datatype any, isJSON bool) error { 51 + var v any 52 52 err := unmarshal(bs, &v, isJSON) 53 53 if err != nil { 54 54 return err ··· 81 81 return err 82 82 } 83 83 84 - func toStringKeys(val interface{}) (interface{}, error) { 84 + func toStringKeys(val any) (any, error) { 85 85 var err error 86 86 switch val := val.(type) { 87 - case map[string]interface{}: 88 - m := make(map[string]interface{}) 87 + case map[string]any: 88 + m := make(map[string]any) 89 89 for k, v := range val { 90 90 m[k], err = toStringKeys(v) 91 91 if err != nil { ··· 93 93 } 94 94 } 95 95 return m, nil 96 - case []interface{}: 97 - l := make([]interface{}, len(val)) 96 + case []any: 97 + l := make([]any, len(val)) 98 98 for i, v := range val { 99 99 l[i], err = toStringKeys(v) 100 100 if err != nil {
+2 -2
modules/migration/messenger.go
··· 4 4 package migration 5 5 6 6 // Messenger is a formatting function similar to i18n.Tr 7 - type Messenger func(key string, args ...interface{}) 7 + type Messenger func(key string, args ...any) 8 8 9 9 // NilMessenger represents an empty formatting function 10 - func NilMessenger(string, ...interface{}) {} 10 + func NilMessenger(string, ...any) {}
+1 -1
modules/nosql/manager_leveldb.go
··· 54 54 // Because we want associate any goroutines created by this call to the main nosqldb context we need to 55 55 // wrap this in a goroutine labelled with the nosqldb context 56 56 done := make(chan struct{}) 57 - var recovered interface{} 57 + var recovered any 58 58 go func() { 59 59 defer func() { 60 60 recovered = recover()
+1 -1
modules/nosql/manager_redis.go
··· 47 47 // Because we want associate any goroutines created by this call to the main nosqldb context we need to 48 48 // wrap this in a goroutine labelled with the nosqldb context 49 49 done := make(chan struct{}) 50 - var recovered interface{} 50 + var recovered any 51 51 go func() { 52 52 defer func() { 53 53 recovered = recover()
+12 -12
modules/packages/composer/metadata.go
··· 38 38 39 39 // Metadata represents the metadata of a Composer package 40 40 type Metadata struct { 41 - Description string `json:"description,omitempty"` 42 - Keywords []string `json:"keywords,omitempty"` 43 - Homepage string `json:"homepage,omitempty"` 44 - License Licenses `json:"license,omitempty"` 45 - Authors []Author `json:"authors,omitempty"` 46 - Autoload map[string]interface{} `json:"autoload,omitempty"` 47 - AutoloadDev map[string]interface{} `json:"autoload-dev,omitempty"` 48 - Extra map[string]interface{} `json:"extra,omitempty"` 49 - Require map[string]string `json:"require,omitempty"` 50 - RequireDev map[string]string `json:"require-dev,omitempty"` 51 - Suggest map[string]string `json:"suggest,omitempty"` 52 - Provide map[string]string `json:"provide,omitempty"` 41 + Description string `json:"description,omitempty"` 42 + Keywords []string `json:"keywords,omitempty"` 43 + Homepage string `json:"homepage,omitempty"` 44 + License Licenses `json:"license,omitempty"` 45 + Authors []Author `json:"authors,omitempty"` 46 + Autoload map[string]any `json:"autoload,omitempty"` 47 + AutoloadDev map[string]any `json:"autoload-dev,omitempty"` 48 + Extra map[string]any `json:"extra,omitempty"` 49 + Require map[string]string `json:"require,omitempty"` 50 + RequireDev map[string]string `json:"require-dev,omitempty"` 51 + Suggest map[string]string `json:"suggest,omitempty"` 52 + Provide map[string]string `json:"provide,omitempty"` 53 53 } 54 54 55 55 // Licenses represents the licenses of a Composer package
+8 -8
modules/packages/helm/metadata.go
··· 55 55 } 56 56 57 57 type Dependency struct { 58 - Name string `json:"name" yaml:"name"` 59 - Version string `json:"version,omitempty" yaml:"version,omitempty"` 60 - Repository string `json:"repository" yaml:"repository"` 61 - Condition string `json:"condition,omitempty" yaml:"condition,omitempty"` 62 - Tags []string `json:"tags,omitempty" yaml:"tags,omitempty"` 63 - Enabled bool `json:"enabled,omitempty" yaml:"enabled,omitempty"` 64 - ImportValues []interface{} `json:"import_values,omitempty" yaml:"import-values,omitempty"` 65 - Alias string `json:"alias,omitempty" yaml:"alias,omitempty"` 58 + Name string `json:"name" yaml:"name"` 59 + Version string `json:"version,omitempty" yaml:"version,omitempty"` 60 + Repository string `json:"repository" yaml:"repository"` 61 + Condition string `json:"condition,omitempty" yaml:"condition,omitempty"` 62 + Tags []string `json:"tags,omitempty" yaml:"tags,omitempty"` 63 + Enabled bool `json:"enabled,omitempty" yaml:"enabled,omitempty"` 64 + ImportValues []any `json:"import_values,omitempty" yaml:"import-values,omitempty"` 65 + Alias string `json:"alias,omitempty" yaml:"alias,omitempty"` 66 66 } 67 67 68 68 // ParseChartArchive parses the metadata of a Helm archive
+7 -7
modules/packages/pub/metadata.go
··· 38 38 39 39 // Metadata represents the metadata of a Pub package 40 40 type Metadata struct { 41 - Description string `json:"description,omitempty"` 42 - ProjectURL string `json:"project_url,omitempty"` 43 - RepositoryURL string `json:"repository_url,omitempty"` 44 - DocumentationURL string `json:"documentation_url,omitempty"` 45 - Readme string `json:"readme,omitempty"` 46 - Pubspec interface{} `json:"pubspec"` 41 + Description string `json:"description,omitempty"` 42 + ProjectURL string `json:"project_url,omitempty"` 43 + RepositoryURL string `json:"repository_url,omitempty"` 44 + DocumentationURL string `json:"documentation_url,omitempty"` 45 + Readme string `json:"readme,omitempty"` 46 + Pubspec any `json:"pubspec"` 47 47 } 48 48 49 49 type pubspecPackage struct { ··· 134 134 p.Repository = "" 135 135 } 136 136 137 - var pubspec interface{} 137 + var pubspec any 138 138 if err := yaml.Unmarshal(buf, &pubspec); err != nil { 139 139 return nil, err 140 140 }
+5 -5
modules/packages/rubygems/marshal.go
··· 40 40 // RubyUserMarshal is a Ruby object that has a marshal_load function. 41 41 type RubyUserMarshal struct { 42 42 Name string 43 - Value interface{} 43 + Value any 44 44 } 45 45 46 46 // RubyUserDef is a Ruby object that has a _load function. 47 47 type RubyUserDef struct { 48 48 Name string 49 - Value interface{} 49 + Value any 50 50 } 51 51 52 52 // RubyObject is a default Ruby object. 53 53 type RubyObject struct { 54 54 Name string 55 - Member map[string]interface{} 55 + Member map[string]any 56 56 } 57 57 58 58 // MarshalEncoder mimics Rubys Marshal class. ··· 71 71 } 72 72 73 73 // Encode encodes the given type 74 - func (e *MarshalEncoder) Encode(v interface{}) error { 74 + func (e *MarshalEncoder) Encode(v any) error { 75 75 if _, err := e.w.Write([]byte{majorVersion, minorVersion}); err != nil { 76 76 return err 77 77 } ··· 83 83 return e.w.Flush() 84 84 } 85 85 86 - func (e *MarshalEncoder) marshal(v interface{}) error { 86 + func (e *MarshalEncoder) marshal(v any) error { 87 87 if v == nil { 88 88 return e.marshalNil() 89 89 }
+2 -2
modules/packages/rubygems/marshal_test.go
··· 12 12 13 13 func TestMinimalEncoder(t *testing.T) { 14 14 cases := []struct { 15 - Value interface{} 15 + Value any 16 16 Expected []byte 17 17 Error error 18 18 }{ ··· 73 73 { 74 74 Value: &RubyObject{ 75 75 Name: "Test", 76 - Member: map[string]interface{}{ 76 + Member: map[string]any{ 77 77 "test": 4, 78 78 }, 79 79 },
+26 -26
modules/packages/rubygems/metadata.go
··· 65 65 Version struct { 66 66 Version string `yaml:"version"` 67 67 } `yaml:"version"` 68 - Platform string `yaml:"platform"` 69 - Authors []string `yaml:"authors"` 70 - Autorequire interface{} `yaml:"autorequire"` 71 - Bindir string `yaml:"bindir"` 72 - CertChain []interface{} `yaml:"cert_chain"` 73 - Date string `yaml:"date"` 68 + Platform string `yaml:"platform"` 69 + Authors []string `yaml:"authors"` 70 + Autorequire any `yaml:"autorequire"` 71 + Bindir string `yaml:"bindir"` 72 + CertChain []any `yaml:"cert_chain"` 73 + Date string `yaml:"date"` 74 74 Dependencies []struct { 75 75 Name string `yaml:"name"` 76 76 Requirement requirement `yaml:"requirement"` ··· 78 78 Prerelease bool `yaml:"prerelease"` 79 79 VersionRequirements requirement `yaml:"version_requirements"` 80 80 } `yaml:"dependencies"` 81 - Description string `yaml:"description"` 82 - Executables []string `yaml:"executables"` 83 - Extensions []interface{} `yaml:"extensions"` 84 - ExtraRdocFiles []string `yaml:"extra_rdoc_files"` 85 - Files []string `yaml:"files"` 86 - Homepage string `yaml:"homepage"` 87 - Licenses []string `yaml:"licenses"` 81 + Description string `yaml:"description"` 82 + Executables []string `yaml:"executables"` 83 + Extensions []any `yaml:"extensions"` 84 + ExtraRdocFiles []string `yaml:"extra_rdoc_files"` 85 + Files []string `yaml:"files"` 86 + Homepage string `yaml:"homepage"` 87 + Licenses []string `yaml:"licenses"` 88 88 Metadata struct { 89 89 BugTrackerURI string `yaml:"bug_tracker_uri"` 90 90 ChangelogURI string `yaml:"changelog_uri"` 91 91 DocumentationURI string `yaml:"documentation_uri"` 92 92 SourceCodeURI string `yaml:"source_code_uri"` 93 93 } `yaml:"metadata"` 94 - PostInstallMessage interface{} `yaml:"post_install_message"` 95 - RdocOptions []interface{} `yaml:"rdoc_options"` 96 - RequirePaths []string `yaml:"require_paths"` 97 - RequiredRubyVersion requirement `yaml:"required_ruby_version"` 98 - RequiredRubygemsVersion requirement `yaml:"required_rubygems_version"` 99 - Requirements []interface{} `yaml:"requirements"` 100 - RubygemsVersion string `yaml:"rubygems_version"` 101 - SigningKey interface{} `yaml:"signing_key"` 102 - SpecificationVersion int `yaml:"specification_version"` 103 - Summary string `yaml:"summary"` 104 - TestFiles []interface{} `yaml:"test_files"` 94 + PostInstallMessage any `yaml:"post_install_message"` 95 + RdocOptions []any `yaml:"rdoc_options"` 96 + RequirePaths []string `yaml:"require_paths"` 97 + RequiredRubyVersion requirement `yaml:"required_ruby_version"` 98 + RequiredRubygemsVersion requirement `yaml:"required_rubygems_version"` 99 + Requirements []any `yaml:"requirements"` 100 + RubygemsVersion string `yaml:"rubygems_version"` 101 + SigningKey any `yaml:"signing_key"` 102 + SpecificationVersion int `yaml:"specification_version"` 103 + Summary string `yaml:"summary"` 104 + TestFiles []any `yaml:"test_files"` 105 105 } 106 106 107 107 type requirement struct { 108 - Requirements [][]interface{} `yaml:"requirements"` 108 + Requirements [][]any `yaml:"requirements"` 109 109 } 110 110 111 111 // AsVersionRequirement converts into []VersionRequirement ··· 119 119 if !ok { 120 120 continue 121 121 } 122 - vm, ok := req[1].(map[string]interface{}) 122 + vm, ok := req[1].(map[string]any) 123 123 if !ok { 124 124 continue 125 125 }
+2 -2
modules/private/manager.go
··· 85 85 Logger string 86 86 Writer string 87 87 Mode string 88 - Config map[string]interface{} 88 + Config map[string]any 89 89 } 90 90 91 91 // AddLogger adds a logger 92 - func AddLogger(ctx context.Context, logger, writer, mode string, config map[string]interface{}) ResponseExtra { 92 + func AddLogger(ctx context.Context, logger, writer, mode string, config map[string]any) ResponseExtra { 93 93 reqURL := setting.LocalURL + "api/internal/manager/add-logger" 94 94 req := newInternalRequest(ctx, reqURL, "POST", LoggerOptions{ 95 95 Logger: logger,
+2 -2
modules/process/context.go
··· 24 24 } 25 25 26 26 // Value is part of the interface for context.Context. We mostly defer to the internal context - but we return this in response to the ProcessContextKey 27 - func (c *Context) Value(key interface{}) interface{} { 27 + func (c *Context) Value(key any) any { 28 28 if key == ProcessContextKey { 29 29 return c 30 30 } ··· 32 32 } 33 33 34 34 // ProcessContextKey is the key under which process contexts are stored 35 - var ProcessContextKey interface{} = "process-context" 35 + var ProcessContextKey any = "process-context" 36 36 37 37 // GetContext will return a process context if one exists 38 38 func GetContext(ctx context.Context) *Context {
+10 -10
modules/session/db.go
··· 17 17 type DBStore struct { 18 18 sid string 19 19 lock sync.RWMutex 20 - data map[interface{}]interface{} 20 + data map[any]any 21 21 } 22 22 23 23 // NewDBStore creates and returns a DB session store. 24 - func NewDBStore(sid string, kv map[interface{}]interface{}) *DBStore { 24 + func NewDBStore(sid string, kv map[any]any) *DBStore { 25 25 return &DBStore{ 26 26 sid: sid, 27 27 data: kv, ··· 29 29 } 30 30 31 31 // Set sets value to given key in session. 32 - func (s *DBStore) Set(key, val interface{}) error { 32 + func (s *DBStore) Set(key, val any) error { 33 33 s.lock.Lock() 34 34 defer s.lock.Unlock() 35 35 ··· 38 38 } 39 39 40 40 // Get gets value by given key in session. 41 - func (s *DBStore) Get(key interface{}) interface{} { 41 + func (s *DBStore) Get(key any) any { 42 42 s.lock.RLock() 43 43 defer s.lock.RUnlock() 44 44 ··· 46 46 } 47 47 48 48 // Delete delete a key from session. 49 - func (s *DBStore) Delete(key interface{}) error { 49 + func (s *DBStore) Delete(key any) error { 50 50 s.lock.Lock() 51 51 defer s.lock.Unlock() 52 52 ··· 79 79 s.lock.Lock() 80 80 defer s.lock.Unlock() 81 81 82 - s.data = make(map[interface{}]interface{}) 82 + s.data = make(map[any]any) 83 83 return nil 84 84 } 85 85 ··· 102 102 return nil, err 103 103 } 104 104 105 - var kv map[interface{}]interface{} 105 + var kv map[any]any 106 106 if len(s.Data) == 0 || s.Expiry.Add(p.maxLifetime) <= timeutil.TimeStampNow() { 107 - kv = make(map[interface{}]interface{}) 107 + kv = make(map[any]any) 108 108 } else { 109 109 kv, err = session.DecodeGob(s.Data) 110 110 if err != nil { ··· 136 136 return nil, err 137 137 } 138 138 139 - var kv map[interface{}]interface{} 139 + var kv map[any]any 140 140 if len(s.Data) == 0 || s.Expiry.Add(p.maxLifetime) <= timeutil.TimeStampNow() { 141 - kv = make(map[interface{}]interface{}) 141 + kv = make(map[any]any) 142 142 } else { 143 143 kv, err = session.DecodeGob(s.Data) 144 144 if err != nil {
+10 -10
modules/session/redis.go
··· 35 35 prefix, sid string 36 36 duration time.Duration 37 37 lock sync.RWMutex 38 - data map[interface{}]interface{} 38 + data map[any]any 39 39 } 40 40 41 41 // NewRedisStore creates and returns a redis session store. 42 - func NewRedisStore(c redis.UniversalClient, prefix, sid string, dur time.Duration, kv map[interface{}]interface{}) *RedisStore { 42 + func NewRedisStore(c redis.UniversalClient, prefix, sid string, dur time.Duration, kv map[any]any) *RedisStore { 43 43 return &RedisStore{ 44 44 c: c, 45 45 prefix: prefix, ··· 50 50 } 51 51 52 52 // Set sets value to given key in session. 53 - func (s *RedisStore) Set(key, val interface{}) error { 53 + func (s *RedisStore) Set(key, val any) error { 54 54 s.lock.Lock() 55 55 defer s.lock.Unlock() 56 56 ··· 59 59 } 60 60 61 61 // Get gets value by given key in session. 62 - func (s *RedisStore) Get(key interface{}) interface{} { 62 + func (s *RedisStore) Get(key any) any { 63 63 s.lock.RLock() 64 64 defer s.lock.RUnlock() 65 65 ··· 67 67 } 68 68 69 69 // Delete delete a key from session. 70 - func (s *RedisStore) Delete(key interface{}) error { 70 + func (s *RedisStore) Delete(key any) error { 71 71 s.lock.Lock() 72 72 defer s.lock.Unlock() 73 73 ··· 100 100 s.lock.Lock() 101 101 defer s.lock.Unlock() 102 102 103 - s.data = make(map[interface{}]interface{}) 103 + s.data = make(map[any]any) 104 104 return nil 105 105 } 106 106 ··· 141 141 } 142 142 } 143 143 144 - var kv map[interface{}]interface{} 144 + var kv map[any]any 145 145 kvs, err := p.c.Get(graceful.GetManager().HammerContext(), psid).Result() 146 146 if err != nil { 147 147 return nil, err 148 148 } 149 149 if len(kvs) == 0 { 150 - kv = make(map[interface{}]interface{}) 150 + kv = make(map[any]any) 151 151 } else { 152 152 kv, err = session.DecodeGob([]byte(kvs)) 153 153 if err != nil { ··· 197 197 return nil, err 198 198 } 199 199 200 - var kv map[interface{}]interface{} 200 + var kv map[any]any 201 201 if len(kvs) == 0 { 202 - kv = make(map[interface{}]interface{}) 202 + kv = make(map[any]any) 203 203 } else { 204 204 kv, err = session.DecodeGob([]byte(kvs)) 205 205 if err != nil {
+3 -3
modules/session/store.go
··· 11 11 12 12 // Store represents a session store 13 13 type Store interface { 14 - Get(interface{}) interface{} 15 - Set(interface{}, interface{}) error 16 - Delete(interface{}) error 14 + Get(any) any 15 + Set(any, any) error 16 + Delete(any) error 17 17 } 18 18 19 19 // RegenerateSession regenerates the underlying session and returns the new store
+7 -7
modules/session/virtual.go
··· 62 62 if o.provider.Exist(sid) { 63 63 return o.provider.Read(sid) 64 64 } 65 - kv := make(map[interface{}]interface{}) 65 + kv := make(map[any]any) 66 66 kv["_old_uid"] = "0" 67 67 return NewVirtualStore(o, sid, kv), nil 68 68 } ··· 107 107 p *VirtualSessionProvider 108 108 sid string 109 109 lock sync.RWMutex 110 - data map[interface{}]interface{} 110 + data map[any]any 111 111 released bool 112 112 } 113 113 114 114 // NewVirtualStore creates and returns a virtual session store. 115 - func NewVirtualStore(p *VirtualSessionProvider, sid string, kv map[interface{}]interface{}) *VirtualStore { 115 + func NewVirtualStore(p *VirtualSessionProvider, sid string, kv map[any]any) *VirtualStore { 116 116 return &VirtualStore{ 117 117 p: p, 118 118 sid: sid, ··· 121 121 } 122 122 123 123 // Set sets value to given key in session. 124 - func (s *VirtualStore) Set(key, val interface{}) error { 124 + func (s *VirtualStore) Set(key, val any) error { 125 125 s.lock.Lock() 126 126 defer s.lock.Unlock() 127 127 ··· 130 130 } 131 131 132 132 // Get gets value by given key in session. 133 - func (s *VirtualStore) Get(key interface{}) interface{} { 133 + func (s *VirtualStore) Get(key any) any { 134 134 s.lock.RLock() 135 135 defer s.lock.RUnlock() 136 136 ··· 138 138 } 139 139 140 140 // Delete delete a key from session. 141 - func (s *VirtualStore) Delete(key interface{}) error { 141 + func (s *VirtualStore) Delete(key any) error { 142 142 s.lock.Lock() 143 143 defer s.lock.Unlock() 144 144 ··· 192 192 s.lock.Lock() 193 193 defer s.lock.Unlock() 194 194 195 - s.data = make(map[interface{}]interface{}) 195 + s.data = make(map[any]any) 196 196 return nil 197 197 }
+2 -2
modules/setting/cron.go
··· 6 6 import "reflect" 7 7 8 8 // GetCronSettings maps the cron subsection to the provided config 9 - func GetCronSettings(name string, config interface{}) (interface{}, error) { 9 + func GetCronSettings(name string, config any) (any, error) { 10 10 return getCronSettings(CfgProvider, name, config) 11 11 } 12 12 13 - func getCronSettings(rootCfg ConfigProvider, name string, config interface{}) (interface{}, error) { 13 + func getCronSettings(rootCfg ConfigProvider, name string, config any) (any, error) { 14 14 if err := rootCfg.Section("cron." + name).MapTo(config); err != nil { 15 15 return config, err 16 16 }
+1 -1
modules/setting/log_test.go
··· 30 30 return manager, manager.Close 31 31 } 32 32 33 - func toJSON(v interface{}) string { 33 + func toJSON(v any) string { 34 34 b, _ := json.MarshalIndent(v, "", "\t") 35 35 return string(b) 36 36 }
+1 -1
modules/storage/minio.go
··· 173 173 return os.ModePerm 174 174 } 175 175 176 - func (m minioFileInfo) Sys() interface{} { 176 + func (m minioFileInfo) Sys() any { 177 177 return nil 178 178 } 179 179
+1 -1
modules/storage/storage.go
··· 20 20 21 21 // ErrInvalidConfiguration is called when there is invalid configuration for a storage 22 22 type ErrInvalidConfiguration struct { 23 - cfg interface{} 23 + cfg any 24 24 err error 25 25 } 26 26
+4 -4
modules/structs/issue.go
··· 140 140 // IssueFormField represents a form field 141 141 // swagger:model 142 142 type IssueFormField struct { 143 - Type IssueFormFieldType `json:"type" yaml:"type"` 144 - ID string `json:"id" yaml:"id"` 145 - Attributes map[string]interface{} `json:"attributes" yaml:"attributes"` 146 - Validations map[string]interface{} `json:"validations" yaml:"validations"` 143 + Type IssueFormFieldType `json:"type" yaml:"type"` 144 + ID string `json:"id" yaml:"id"` 145 + Attributes map[string]any `json:"attributes" yaml:"attributes"` 146 + Validations map[string]any `json:"validations" yaml:"validations"` 147 147 } 148 148 149 149 // IssueTemplate represents an issue template for a repository
+1 -1
modules/structs/repo_file.go
··· 166 166 167 167 // FileDeleteResponse contains information about a repo's file that was deleted 168 168 type FileDeleteResponse struct { 169 - Content interface{} `json:"content"` // to be set to nil 169 + Content any `json:"content"` // to be set to nil 170 170 Commit *FileCommitResponse `json:"commit"` 171 171 Verification *PayloadCommitVerification `json:"verification"` 172 172 }
+6 -6
modules/structs/repo_watch.go
··· 9 9 10 10 // WatchInfo represents an API watch status of one repository 11 11 type WatchInfo struct { 12 - Subscribed bool `json:"subscribed"` 13 - Ignored bool `json:"ignored"` 14 - Reason interface{} `json:"reason"` 15 - CreatedAt time.Time `json:"created_at"` 16 - URL string `json:"url"` 17 - RepositoryURL string `json:"repository_url"` 12 + Subscribed bool `json:"subscribed"` 13 + Ignored bool `json:"ignored"` 14 + Reason any `json:"reason"` 15 + CreatedAt time.Time `json:"created_at"` 16 + URL string `json:"url"` 17 + RepositoryURL string `json:"repository_url"` 18 18 }
+1 -1
modules/svg/svg.go
··· 49 49 } 50 50 51 51 // RenderHTML renders icons - arguments icon name (string), size (int), class (string) 52 - func RenderHTML(icon string, others ...interface{}) template.HTML { 52 + func RenderHTML(icon string, others ...any) template.HTML { 53 53 size, class := html.ParseSizeAndClass(defaultSize, "", others...) 54 54 55 55 if svgStr, ok := SVGs[icon]; ok {
+3 -3
modules/templates/helper.go
··· 27 27 28 28 // NewFuncMap returns functions for injecting to templates 29 29 func NewFuncMap() template.FuncMap { 30 - return map[string]interface{}{ 30 + return map[string]any{ 31 31 "DumpVar": dumpVar, 32 32 33 33 // ----------------------------------------------------------------- ··· 142 142 "DefaultTheme": func() string { 143 143 return setting.UI.DefaultTheme 144 144 }, 145 - "NotificationSettings": func() map[string]interface{} { 146 - return map[string]interface{}{ 145 + "NotificationSettings": func() map[string]any { 146 + return map[string]any{ 147 147 "MinTimeout": int(setting.UI.Notification.MinTimeout / time.Millisecond), 148 148 "TimeoutStep": int(setting.UI.Notification.TimeoutStep / time.Millisecond), 149 149 "MaxTimeout": int(setting.UI.Notification.MaxTimeout / time.Millisecond),
+1 -1
modules/templates/htmlrenderer.go
··· 39 39 40 40 var ErrTemplateNotInitialized = errors.New("template system is not initialized, check your log for errors") 41 41 42 - func (h *HTMLRender) HTML(w io.Writer, status int, name string, data interface{}) error { 42 + func (h *HTMLRender) HTML(w io.Writer, status int, name string, data any) error { 43 43 if respWriter, ok := w.(http.ResponseWriter); ok { 44 44 if respWriter.Header().Get("Content-Type") == "" { 45 45 respWriter.Header().Set("Content-Type", "text/html; charset=utf-8")
+1 -1
modules/templates/scopedtmpl/scopedtmpl.go
··· 15 15 ) 16 16 17 17 type TemplateExecutor interface { 18 - Execute(wr io.Writer, data interface{}) error 18 + Execute(wr io.Writer, data any) error 19 19 } 20 20 21 21 type ScopedTemplate struct {
+4 -4
modules/templates/util_avatar.go
··· 30 30 } 31 31 32 32 // Avatar renders user avatars. args: user, size (int), class (string) 33 - func Avatar(ctx context.Context, item interface{}, others ...interface{}) template.HTML { 33 + func Avatar(ctx context.Context, item any, others ...any) template.HTML { 34 34 size, class := gitea_html.ParseSizeAndClass(avatars.DefaultAvatarPixelSize, avatars.DefaultAvatarClass, others...) 35 35 36 36 switch t := item.(type) { ··· 55 55 } 56 56 57 57 // AvatarByAction renders user avatars from action. args: action, size (int), class (string) 58 - func AvatarByAction(ctx context.Context, action *activities_model.Action, others ...interface{}) template.HTML { 58 + func AvatarByAction(ctx context.Context, action *activities_model.Action, others ...any) template.HTML { 59 59 action.LoadActUser(ctx) 60 60 return Avatar(ctx, action.ActUser, others...) 61 61 } 62 62 63 63 // RepoAvatar renders repo avatars. args: repo, size(int), class (string) 64 - func RepoAvatar(repo *repo_model.Repository, others ...interface{}) template.HTML { 64 + func RepoAvatar(repo *repo_model.Repository, others ...any) template.HTML { 65 65 size, class := gitea_html.ParseSizeAndClass(avatars.DefaultAvatarPixelSize, avatars.DefaultAvatarClass, others...) 66 66 67 67 src := repo.RelAvatarLink() ··· 72 72 } 73 73 74 74 // AvatarByEmail renders avatars by email address. args: email, name, size (int), class (string) 75 - func AvatarByEmail(ctx context.Context, email, name string, others ...interface{}) template.HTML { 75 + func AvatarByEmail(ctx context.Context, email, name string, others ...any) template.HTML { 76 76 size, class := gitea_html.ParseSizeAndClass(avatars.DefaultAvatarPixelSize, avatars.DefaultAvatarClass, others...) 77 77 src := avatars.GenerateEmailAvatarFastLink(ctx, email, size*setting.Avatar.RenderedSizeFactor) 78 78
+1 -1
modules/templates/util_misc.go
··· 174 174 return strings.HasPrefix(mimeType, "image/") 175 175 } 176 176 177 - func TabSizeClass(ec interface{}, filename string) string { 177 + func TabSizeClass(ec any, filename string) string { 178 178 var ( 179 179 value *editorconfig.Editorconfig 180 180 ok bool
+1 -1
modules/test/context_tests.go
··· 154 154 return nil, nil 155 155 } 156 156 157 - func (tr *mockRender) HTML(w io.Writer, status int, _ string, _ interface{}) error { 157 + func (tr *mockRender) HTML(w io.Writer, status int, _ string, _ any) error { 158 158 if resp, ok := w.(http.ResponseWriter); ok { 159 159 resp.WriteHeader(status) 160 160 }
+1 -1
modules/testlogger/testlogger.go
··· 137 137 } 138 138 139 139 // Printf takes a format and args and prints the string to os.Stdout 140 - func Printf(format string, args ...interface{}) { 140 + func Printf(format string, args ...any) { 141 141 if log.CanColorStdout { 142 142 for i := 0; i < len(args); i++ { 143 143 args[i] = log.NewColoredValue(args[i])
+2 -2
modules/translation/i18n/format.go
··· 9 9 ) 10 10 11 11 // Format formats provided arguments for a given translated message 12 - func Format(format string, args ...interface{}) (msg string, err error) { 12 + func Format(format string, args ...any) (msg string, err error) { 13 13 if len(args) == 0 { 14 14 return format, nil 15 15 } 16 16 17 - fmtArgs := make([]interface{}, 0, len(args)) 17 + fmtArgs := make([]any, 0, len(args)) 18 18 for _, arg := range args { 19 19 val := reflect.ValueOf(arg) 20 20 if val.Kind() == reflect.Slice {
+2 -2
modules/translation/i18n/i18n.go
··· 11 11 12 12 type Locale interface { 13 13 // Tr translates a given key and arguments for a language 14 - Tr(trKey string, trArgs ...interface{}) string 14 + Tr(trKey string, trArgs ...any) string 15 15 // Has reports if a locale has a translation for a given key 16 16 Has(trKey string) bool 17 17 } ··· 21 21 io.Closer 22 22 23 23 // Tr translates a given key and arguments for a language 24 - Tr(lang, trKey string, trArgs ...interface{}) string 24 + Tr(lang, trKey string, trArgs ...any) string 25 25 // Has reports if a locale has a translation for a given key 26 26 Has(lang, trKey string) bool 27 27 // SetDefaultLang sets the default language to fall back to
+2 -2
modules/translation/i18n/localestore.go
··· 86 86 } 87 87 88 88 // Tr translates content to target language. fall back to default language. 89 - func (store *localeStore) Tr(lang, trKey string, trArgs ...interface{}) string { 89 + func (store *localeStore) Tr(lang, trKey string, trArgs ...any) string { 90 90 l, _ := store.Locale(lang) 91 91 92 92 return l.Tr(trKey, trArgs...) ··· 119 119 } 120 120 121 121 // Tr translates content to locale language. fall back to default language. 122 - func (l *locale) Tr(trKey string, trArgs ...interface{}) string { 122 + func (l *locale) Tr(trKey string, trArgs ...any) string { 123 123 format := trKey 124 124 125 125 idx, ok := l.store.trKeyToIdxMap[trKey]
+2 -2
modules/translation/mock.go
··· 14 14 return "en" 15 15 } 16 16 17 - func (l MockLocale) Tr(s string, _ ...interface{}) string { 17 + func (l MockLocale) Tr(s string, _ ...any) string { 18 18 return s 19 19 } 20 20 21 - func (l MockLocale) TrN(_cnt interface{}, key1, _keyN string, _args ...interface{}) string { 21 + func (l MockLocale) TrN(_cnt any, key1, _keyN string, _args ...any) string { 22 22 return key1 23 23 } 24 24
+5 -5
modules/util/error.go
··· 37 37 } 38 38 39 39 // NewSilentWrapErrorf returns an error that formats as the given text but unwraps as the provided error 40 - func NewSilentWrapErrorf(unwrap error, message string, args ...interface{}) error { 40 + func NewSilentWrapErrorf(unwrap error, message string, args ...any) error { 41 41 if len(args) == 0 { 42 42 return SilentWrap{Message: message, Err: unwrap} 43 43 } ··· 45 45 } 46 46 47 47 // NewInvalidArgumentErrorf returns an error that formats as the given text but unwraps as an ErrInvalidArgument 48 - func NewInvalidArgumentErrorf(message string, args ...interface{}) error { 48 + func NewInvalidArgumentErrorf(message string, args ...any) error { 49 49 return NewSilentWrapErrorf(ErrInvalidArgument, message, args...) 50 50 } 51 51 52 52 // NewPermissionDeniedErrorf returns an error that formats as the given text but unwraps as an ErrPermissionDenied 53 - func NewPermissionDeniedErrorf(message string, args ...interface{}) error { 53 + func NewPermissionDeniedErrorf(message string, args ...any) error { 54 54 return NewSilentWrapErrorf(ErrPermissionDenied, message, args...) 55 55 } 56 56 57 57 // NewAlreadyExistErrorf returns an error that formats as the given text but unwraps as an ErrAlreadyExist 58 - func NewAlreadyExistErrorf(message string, args ...interface{}) error { 58 + func NewAlreadyExistErrorf(message string, args ...any) error { 59 59 return NewSilentWrapErrorf(ErrAlreadyExist, message, args...) 60 60 } 61 61 62 62 // NewNotExistErrorf returns an error that formats as the given text but unwraps as an ErrNotExist 63 - func NewNotExistErrorf(message string, args ...interface{}) error { 63 + func NewNotExistErrorf(message string, args ...any) error { 64 64 return NewSilentWrapErrorf(ErrNotExist, message, args...) 65 65 }
+2 -2
modules/util/pack.go
··· 9 9 ) 10 10 11 11 // PackData uses gob to encode the given data in sequence 12 - func PackData(data ...interface{}) ([]byte, error) { 12 + func PackData(data ...any) ([]byte, error) { 13 13 var buf bytes.Buffer 14 14 enc := gob.NewEncoder(&buf) 15 15 for _, datum := range data { ··· 21 21 } 22 22 23 23 // UnpackData uses gob to decode the given data in sequence 24 - func UnpackData(buf []byte, data ...interface{}) error { 24 + func UnpackData(buf []byte, data ...any) error { 25 25 r := bytes.NewReader(buf) 26 26 enc := gob.NewDecoder(r) 27 27 for _, datum := range data {
+1 -1
modules/util/paginate.go
··· 7 7 8 8 // PaginateSlice cut a slice as per pagination options 9 9 // if page = 0 it do not paginate 10 - func PaginateSlice(list interface{}, page, pageSize int) interface{} { 10 + func PaginateSlice(list any, page, pageSize int) any { 11 11 if page <= 0 || pageSize <= 0 { 12 12 return list 13 13 }
+2 -2
modules/util/rotatingfilewriter/writer.go
··· 39 39 cancelReleaseReopen func() 40 40 } 41 41 42 - var ErrorPrintf func(format string, args ...interface{}) 42 + var ErrorPrintf func(format string, args ...any) 43 43 44 44 // 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 45 - func errorf(format string, args ...interface{}) { 45 + func errorf(format string, args ...any) { 46 46 if ErrorPrintf != nil { 47 47 ErrorPrintf("rotatingfilewriter: "+format+"\n", args...) 48 48 }
+2 -2
modules/util/util.go
··· 174 174 } 175 175 176 176 // ToInt64 transform a given int into int64. 177 - func ToInt64(number interface{}) (int64, error) { 177 + func ToInt64(number any) (int64, error) { 178 178 var value int64 179 179 switch v := number.(type) { 180 180 case int: ··· 216 216 } 217 217 218 218 // ToFloat64 transform a given int into float64. 219 - func ToFloat64(number interface{}) (float64, error) { 219 + func ToFloat64(number any) (float64, error) { 220 220 var value float64 221 221 switch v := number.(type) { 222 222 case int:
+8 -8
modules/validation/binding.go
··· 46 46 IsMatch: func(rule string) bool { 47 47 return strings.HasPrefix(rule, "GitRefName") 48 48 }, 49 - IsValid: func(errs binding.Errors, name string, val interface{}) (bool, binding.Errors) { 49 + IsValid: func(errs binding.Errors, name string, val any) (bool, binding.Errors) { 50 50 str := fmt.Sprintf("%v", val) 51 51 52 52 if !git.IsValidRefPattern(str) { ··· 64 64 IsMatch: func(rule string) bool { 65 65 return strings.HasPrefix(rule, "ValidUrl") 66 66 }, 67 - IsValid: func(errs binding.Errors, name string, val interface{}) (bool, binding.Errors) { 67 + IsValid: func(errs binding.Errors, name string, val any) (bool, binding.Errors) { 68 68 str := fmt.Sprintf("%v", val) 69 69 if len(str) != 0 && !IsValidURL(str) { 70 70 errs.Add([]string{name}, binding.ERR_URL, "Url") ··· 82 82 IsMatch: func(rule string) bool { 83 83 return strings.HasPrefix(rule, "ValidSiteUrl") 84 84 }, 85 - IsValid: func(errs binding.Errors, name string, val interface{}) (bool, binding.Errors) { 85 + IsValid: func(errs binding.Errors, name string, val any) (bool, binding.Errors) { 86 86 str := fmt.Sprintf("%v", val) 87 87 if len(str) != 0 && !IsValidSiteURL(str) { 88 88 errs.Add([]string{name}, binding.ERR_URL, "Url") ··· 103 103 }) 104 104 } 105 105 106 - func globPatternValidator(errs binding.Errors, name string, val interface{}) (bool, binding.Errors) { 106 + func globPatternValidator(errs binding.Errors, name string, val any) (bool, binding.Errors) { 107 107 str := fmt.Sprintf("%v", val) 108 108 109 109 if len(str) != 0 { ··· 125 125 }) 126 126 } 127 127 128 - func regexPatternValidator(errs binding.Errors, name string, val interface{}) (bool, binding.Errors) { 128 + func regexPatternValidator(errs binding.Errors, name string, val any) (bool, binding.Errors) { 129 129 str := fmt.Sprintf("%v", val) 130 130 131 131 if _, err := regexp.Compile(str); err != nil { ··· 141 141 IsMatch: func(rule string) bool { 142 142 return rule == "GlobOrRegexPattern" 143 143 }, 144 - IsValid: func(errs binding.Errors, name string, val interface{}) (bool, binding.Errors) { 144 + IsValid: func(errs binding.Errors, name string, val any) (bool, binding.Errors) { 145 145 str := strings.TrimSpace(fmt.Sprintf("%v", val)) 146 146 147 147 if len(str) >= 2 && strings.HasPrefix(str, "/") && strings.HasSuffix(str, "/") { ··· 157 157 IsMatch: func(rule string) bool { 158 158 return rule == "Username" 159 159 }, 160 - IsValid: func(errs binding.Errors, name string, val interface{}) (bool, binding.Errors) { 160 + IsValid: func(errs binding.Errors, name string, val any) (bool, binding.Errors) { 161 161 str := fmt.Sprintf("%v", val) 162 162 if !IsValidUsername(str) { 163 163 errs.Add([]string{name}, ErrUsername, "invalid username") ··· 173 173 IsMatch: func(rule string) bool { 174 174 return strings.HasPrefix(rule, "ValidGroupTeamMap") 175 175 }, 176 - IsValid: func(errs binding.Errors, name string, val interface{}) (bool, binding.Errors) { 176 + IsValid: func(errs binding.Errors, name string, val any) (bool, binding.Errors) { 177 177 _, err := auth.UnmarshalGroupTeamMapping(fmt.Sprintf("%v", val)) 178 178 if err != nil { 179 179 errs.Add([]string{name}, ErrInvalidGroupTeamMap, err.Error())
+1 -1
modules/validation/binding_test.go
··· 20 20 type ( 21 21 validationTestCase struct { 22 22 description string 23 - data interface{} 23 + data any 24 24 expectedErrors binding.Errors 25 25 } 26 26
+2 -2
modules/web/middleware/binding.go
··· 25 25 } 26 26 27 27 // AssignForm assign form values back to the template data. 28 - func AssignForm(form interface{}, data map[string]interface{}) { 28 + func AssignForm(form any, data map[string]any) { 29 29 typ := reflect.TypeOf(form) 30 30 val := reflect.ValueOf(form) 31 31 ··· 79 79 } 80 80 81 81 // Validate validate TODO: 82 - func Validate(errs binding.Errors, data map[string]interface{}, f Form, l translation.Locale) binding.Errors { 82 + func Validate(errs binding.Errors, data map[string]any, f Form, l translation.Locale) binding.Errors { 83 83 if errs.Len() == 0 { 84 84 return errs 85 85 }
+22 -22
modules/web/route.go
··· 25 25 } 26 26 27 27 // SetForm set the form object 28 - func SetForm(dataStore middleware.ContextDataStore, obj interface{}) { 28 + func SetForm(dataStore middleware.ContextDataStore, obj any) { 29 29 dataStore.GetData()["__form"] = obj 30 30 } 31 31 32 32 // GetForm returns the validate form information 33 - func GetForm(dataStore middleware.ContextDataStore) interface{} { 33 + func GetForm(dataStore middleware.ContextDataStore) any { 34 34 return dataStore.GetData()["__form"] 35 35 } 36 36 ··· 38 38 type Route struct { 39 39 R chi.Router 40 40 curGroupPrefix string 41 - curMiddlewares []interface{} 41 + curMiddlewares []any 42 42 } 43 43 44 44 // NewRoute creates a new route ··· 48 48 } 49 49 50 50 // Use supports two middlewares 51 - func (r *Route) Use(middlewares ...interface{}) { 51 + func (r *Route) Use(middlewares ...any) { 52 52 for _, m := range middlewares { 53 53 r.R.Use(toHandlerProvider(m)) 54 54 } 55 55 } 56 56 57 57 // Group mounts a sub-Router along a `pattern` string. 58 - func (r *Route) Group(pattern string, fn func(), middlewares ...interface{}) { 58 + func (r *Route) Group(pattern string, fn func(), middlewares ...any) { 59 59 previousGroupPrefix := r.curGroupPrefix 60 60 previousMiddlewares := r.curMiddlewares 61 61 r.curGroupPrefix += pattern ··· 111 111 } 112 112 113 113 // Any delegate requests for all methods 114 - func (r *Route) Any(pattern string, h ...interface{}) { 114 + func (r *Route) Any(pattern string, h ...any) { 115 115 middlewares, handlerFunc := r.wrapMiddlewareAndHandler(h) 116 116 r.R.With(middlewares...).HandleFunc(r.getPattern(pattern), handlerFunc) 117 117 } 118 118 119 119 // RouteMethods delegate special methods, it is an alias of "Methods", while the "pattern" is the first parameter 120 - func (r *Route) RouteMethods(pattern, methods string, h ...interface{}) { 120 + func (r *Route) RouteMethods(pattern, methods string, h ...any) { 121 121 r.Methods(methods, pattern, h) 122 122 } 123 123 124 124 // Delete delegate delete method 125 - func (r *Route) Delete(pattern string, h ...interface{}) { 125 + func (r *Route) Delete(pattern string, h ...any) { 126 126 r.Methods("DELETE", pattern, h) 127 127 } 128 128 129 129 // Get delegate get method 130 - func (r *Route) Get(pattern string, h ...interface{}) { 130 + func (r *Route) Get(pattern string, h ...any) { 131 131 r.Methods("GET", pattern, h) 132 132 } 133 133 134 134 // GetOptions delegate get and options method 135 - func (r *Route) GetOptions(pattern string, h ...interface{}) { 135 + func (r *Route) GetOptions(pattern string, h ...any) { 136 136 r.Methods("GET,OPTIONS", pattern, h) 137 137 } 138 138 139 139 // PostOptions delegate post and options method 140 - func (r *Route) PostOptions(pattern string, h ...interface{}) { 140 + func (r *Route) PostOptions(pattern string, h ...any) { 141 141 r.Methods("POST,OPTIONS", pattern, h) 142 142 } 143 143 144 144 // Head delegate head method 145 - func (r *Route) Head(pattern string, h ...interface{}) { 145 + func (r *Route) Head(pattern string, h ...any) { 146 146 r.Methods("HEAD", pattern, h) 147 147 } 148 148 149 149 // Post delegate post method 150 - func (r *Route) Post(pattern string, h ...interface{}) { 150 + func (r *Route) Post(pattern string, h ...any) { 151 151 r.Methods("POST", pattern, h) 152 152 } 153 153 154 154 // Put delegate put method 155 - func (r *Route) Put(pattern string, h ...interface{}) { 155 + func (r *Route) Put(pattern string, h ...any) { 156 156 r.Methods("PUT", pattern, h) 157 157 } 158 158 159 159 // Patch delegate patch method 160 - func (r *Route) Patch(pattern string, h ...interface{}) { 160 + func (r *Route) Patch(pattern string, h ...any) { 161 161 r.Methods("PATCH", pattern, h) 162 162 } 163 163 ··· 172 172 } 173 173 174 174 // Combo delegates requests to Combo 175 - func (r *Route) Combo(pattern string, h ...interface{}) *Combo { 175 + func (r *Route) Combo(pattern string, h ...any) *Combo { 176 176 return &Combo{r, pattern, h} 177 177 } 178 178 ··· 180 180 type Combo struct { 181 181 r *Route 182 182 pattern string 183 - h []interface{} 183 + h []any 184 184 } 185 185 186 186 // Get delegates Get method 187 - func (c *Combo) Get(h ...interface{}) *Combo { 187 + func (c *Combo) Get(h ...any) *Combo { 188 188 c.r.Get(c.pattern, append(c.h, h...)...) 189 189 return c 190 190 } 191 191 192 192 // Post delegates Post method 193 - func (c *Combo) Post(h ...interface{}) *Combo { 193 + func (c *Combo) Post(h ...any) *Combo { 194 194 c.r.Post(c.pattern, append(c.h, h...)...) 195 195 return c 196 196 } 197 197 198 198 // Delete delegates Delete method 199 - func (c *Combo) Delete(h ...interface{}) *Combo { 199 + func (c *Combo) Delete(h ...any) *Combo { 200 200 c.r.Delete(c.pattern, append(c.h, h...)...) 201 201 return c 202 202 } 203 203 204 204 // Put delegates Put method 205 - func (c *Combo) Put(h ...interface{}) *Combo { 205 + func (c *Combo) Put(h ...any) *Combo { 206 206 c.r.Put(c.pattern, append(c.h, h...)...) 207 207 return c 208 208 } 209 209 210 210 // Patch delegates Patch method 211 - func (c *Combo) Patch(h ...interface{}) *Combo { 211 + func (c *Combo) Patch(h ...any) *Combo { 212 212 c.r.Patch(c.pattern, append(c.h, h...)...) 213 213 return c 214 214 }
+1 -1
modules/web/routing/context.go
··· 37 37 } 38 38 39 39 // UpdatePanicError updates a context's error info, a panic may be recovered by other middlewares, but we still need to know that. 40 - func UpdatePanicError(ctx context.Context, err interface{}) { 40 + func UpdatePanicError(ctx context.Context, err any) { 41 41 record, ok := ctx.Value(contextKey).(*requestRecord) 42 42 if !ok { 43 43 return
+1 -1
modules/web/routing/funcinfo.go
··· 35 35 } 36 36 37 37 // GetFuncInfo returns the FuncInfo for a provided function and friendlyname 38 - func GetFuncInfo(fn interface{}, friendlyName ...string) *FuncInfo { 38 + func GetFuncInfo(fn any, friendlyName ...string) *FuncInfo { 39 39 // ptr represents the memory position of the function passed in as v. 40 40 // This will be used as program counter in FuncForPC below 41 41 ptr := reflect.ValueOf(fn).Pointer()
+1 -1
modules/web/routing/requestrecord.go
··· 24 24 // mutable fields 25 25 isLongPolling bool 26 26 funcInfo *FuncInfo 27 - panicError interface{} 27 + panicError any 28 28 }
+2 -2
routers/api/actions/runner/utils.go
··· 116 116 } 117 117 118 118 func generateTaskContext(t *actions_model.ActionTask) *structpb.Struct { 119 - event := map[string]interface{}{} 119 + event := map[string]any{} 120 120 _ = json.Unmarshal([]byte(t.Job.Run.EventPayload), &event) 121 121 122 122 // TriggerEvent is added in https://github.com/go-gitea/gitea/pull/25229 ··· 136 136 137 137 refName := git.RefName(t.Job.Run.Ref) 138 138 139 - taskContext, err := structpb.NewStruct(map[string]interface{}{ 139 + taskContext, err := structpb.NewStruct(map[string]any{ 140 140 // standard contexts, see https://docs.github.com/en/actions/learn-github-actions/contexts#github-context 141 141 "action": "", // string, The name of the action currently running, or the id of a step. GitHub removes special characters, and uses the name __run when the current step runs a script without an id. If you use the same action more than once in the same job, the name will include a suffix with the sequence number with underscore before it. For example, the first script you run will have the name __run, and the second script will be named __run_2. Similarly, the second invocation of actions/checkout will be actionscheckout2. 142 142 "action_path": "", // string, The path where an action is located. This property is only supported in composite actions. You can use this path to access files located in the same repository as the action.
+1 -1
routers/api/packages/alpine/alpine.go
··· 24 24 alpine_service "code.gitea.io/gitea/services/packages/alpine" 25 25 ) 26 26 27 - func apiError(ctx *context.Context, status int, obj interface{}) { 27 + func apiError(ctx *context.Context, status int, obj any) { 28 28 helper.LogAndProcessError(ctx, status, obj, func(message string) { 29 29 ctx.PlainText(status, message) 30 30 })
+1 -1
routers/api/packages/cargo/cargo.go
··· 33 33 Message string `json:"detail"` 34 34 } 35 35 36 - func apiError(ctx *context.Context, status int, obj interface{}) { 36 + func apiError(ctx *context.Context, status int, obj any) { 37 37 helper.LogAndProcessError(ctx, status, obj, func(message string) { 38 38 ctx.JSON(status, StatusResponse{ 39 39 OK: false,
+1 -1
routers/api/packages/chef/chef.go
··· 24 24 packages_service "code.gitea.io/gitea/services/packages" 25 25 ) 26 26 27 - func apiError(ctx *context.Context, status int, obj interface{}) { 27 + func apiError(ctx *context.Context, status int, obj any) { 28 28 type Error struct { 29 29 ErrorMessages []string `json:"error_messages"` 30 30 }
+1 -1
routers/api/packages/composer/composer.go
··· 26 26 "github.com/hashicorp/go-version" 27 27 ) 28 28 29 - func apiError(ctx *context.Context, status int, obj interface{}) { 29 + func apiError(ctx *context.Context, status int, obj any) { 30 30 helper.LogAndProcessError(ctx, status, obj, func(message string) { 31 31 type Error struct { 32 32 Status int `json:"status"`
+4 -4
routers/api/packages/conan/conan.go
··· 47 47 ) 48 48 ) 49 49 50 - func jsonResponse(ctx *context.Context, status int, obj interface{}) { 50 + func jsonResponse(ctx *context.Context, status int, obj any) { 51 51 // https://github.com/conan-io/conan/issues/6613 52 52 ctx.Resp.Header().Set("Content-Type", "application/json") 53 53 ctx.Status(status) ··· 56 56 } 57 57 } 58 58 59 - func apiError(ctx *context.Context, status int, obj interface{}) { 59 + func apiError(ctx *context.Context, status int, obj any) { 60 60 helper.LogAndProcessError(ctx, status, obj, func(message string) { 61 61 jsonResponse(ctx, status, map[string]string{ 62 62 "message": message, ··· 796 796 return 797 797 } 798 798 799 - files := make(map[string]interface{}) 799 + files := make(map[string]any) 800 800 for _, pf := range pfs { 801 801 files[pf.Name] = nil 802 802 } 803 803 804 804 type FileList struct { 805 - Files map[string]interface{} `json:"files"` 805 + Files map[string]any `json:"files"` 806 806 } 807 807 808 808 jsonResponse(ctx, http.StatusOK, &FileList{
+1 -1
routers/api/packages/conda/conda.go
··· 24 24 "github.com/dsnet/compress/bzip2" 25 25 ) 26 26 27 - func apiError(ctx *context.Context, status int, obj interface{}) { 27 + func apiError(ctx *context.Context, status int, obj any) { 28 28 helper.LogAndProcessError(ctx, status, obj, func(message string) { 29 29 ctx.JSON(status, struct { 30 30 Reason string `json:"reason"`
+1 -1
routers/api/packages/container/container.go
··· 75 75 resp.WriteHeader(h.Status) 76 76 } 77 77 78 - func jsonResponse(ctx *context.Context, status int, obj interface{}) { 78 + func jsonResponse(ctx *context.Context, status int, obj any) { 79 79 setResponseHeaders(ctx.Resp, &containerHeaders{ 80 80 Status: status, 81 81 ContentType: "application/json",
+1 -1
routers/api/packages/cran/cran.go
··· 21 21 packages_service "code.gitea.io/gitea/services/packages" 22 22 ) 23 23 24 - func apiError(ctx *context.Context, status int, obj interface{}) { 24 + func apiError(ctx *context.Context, status int, obj any) { 25 25 helper.LogAndProcessError(ctx, status, obj, func(message string) { 26 26 ctx.PlainText(status, message) 27 27 })
+1 -1
routers/api/packages/debian/debian.go
··· 23 23 debian_service "code.gitea.io/gitea/services/packages/debian" 24 24 ) 25 25 26 - func apiError(ctx *context.Context, status int, obj interface{}) { 26 + func apiError(ctx *context.Context, status int, obj any) { 27 27 helper.LogAndProcessError(ctx, status, obj, func(message string) { 28 28 ctx.PlainText(status, message) 29 29 })
+1 -1
routers/api/packages/generic/generic.go
··· 22 22 filenameRegex = packageNameRegex 23 23 ) 24 24 25 - func apiError(ctx *context.Context, status int, obj interface{}) { 25 + func apiError(ctx *context.Context, status int, obj any) { 26 26 helper.LogAndProcessError(ctx, status, obj, func(message string) { 27 27 ctx.PlainText(status, message) 28 28 })
+1 -1
routers/api/packages/goproxy/goproxy.go
··· 20 20 packages_service "code.gitea.io/gitea/services/packages" 21 21 ) 22 22 23 - func apiError(ctx *context.Context, status int, obj interface{}) { 23 + func apiError(ctx *context.Context, status int, obj any) { 24 24 helper.LogAndProcessError(ctx, status, obj, func(message string) { 25 25 ctx.PlainText(status, message) 26 26 })
+1 -1
routers/api/packages/helm/helm.go
··· 26 26 "gopkg.in/yaml.v3" 27 27 ) 28 28 29 - func apiError(ctx *context.Context, status int, obj interface{}) { 29 + func apiError(ctx *context.Context, status int, obj any) { 30 30 helper.LogAndProcessError(ctx, status, obj, func(message string) { 31 31 type Error struct { 32 32 Error string `json:"error"`
+1 -1
routers/api/packages/helper/helper.go
··· 17 17 18 18 // LogAndProcessError logs an error and calls a custom callback with the processed error message. 19 19 // If the error is an InternalServerError the message is stripped if the user is not an admin. 20 - func LogAndProcessError(ctx *context.Context, status int, obj interface{}, cb func(string)) { 20 + func LogAndProcessError(ctx *context.Context, status int, obj any, cb func(string)) { 21 21 var message string 22 22 if err, ok := obj.(error); ok { 23 23 message = err.Error()
+1 -1
routers/api/packages/maven/maven.go
··· 47 47 illegalCharacters = regexp.MustCompile(`[\\/:"<>|?\*]`) 48 48 ) 49 49 50 - func apiError(ctx *context.Context, status int, obj interface{}) { 50 + func apiError(ctx *context.Context, status int, obj any) { 51 51 helper.LogAndProcessError(ctx, status, obj, func(message string) { 52 52 ctx.PlainText(status, message) 53 53 })
+1 -1
routers/api/packages/npm/npm.go
··· 30 30 // errInvalidTagName indicates an invalid tag name 31 31 var errInvalidTagName = errors.New("The tag name is invalid") 32 32 33 - func apiError(ctx *context.Context, status int, obj interface{}) { 33 + func apiError(ctx *context.Context, status int, obj any) { 34 34 helper.LogAndProcessError(ctx, status, obj, func(message string) { 35 35 ctx.JSON(status, map[string]string{ 36 36 "error": message,
+2 -2
routers/api/packages/nuget/nuget.go
··· 25 25 packages_service "code.gitea.io/gitea/services/packages" 26 26 ) 27 27 28 - func apiError(ctx *context.Context, status int, obj interface{}) { 28 + func apiError(ctx *context.Context, status int, obj any) { 29 29 helper.LogAndProcessError(ctx, status, obj, func(message string) { 30 30 ctx.JSON(status, map[string]string{ 31 31 "Message": message, ··· 33 33 }) 34 34 } 35 35 36 - func xmlResponse(ctx *context.Context, status int, obj interface{}) { 36 + func xmlResponse(ctx *context.Context, status int, obj any) { 37 37 ctx.Resp.Header().Set("Content-Type", "application/atom+xml; charset=utf-8") 38 38 ctx.Resp.WriteHeader(status) 39 39 if _, err := ctx.Resp.Write([]byte(xml.Header)); err != nil {
+6 -6
routers/api/packages/pub/pub.go
··· 25 25 packages_service "code.gitea.io/gitea/services/packages" 26 26 ) 27 27 28 - func jsonResponse(ctx *context.Context, status int, obj interface{}) { 28 + func jsonResponse(ctx *context.Context, status int, obj any) { 29 29 resp := ctx.Resp 30 30 resp.Header().Set("Content-Type", "application/vnd.pub.v2+json") 31 31 resp.WriteHeader(status) ··· 34 34 } 35 35 } 36 36 37 - func apiError(ctx *context.Context, status int, obj interface{}) { 37 + func apiError(ctx *context.Context, status int, obj any) { 38 38 type Error struct { 39 39 Code string `json:"code"` 40 40 Message string `json:"message"` ··· 60 60 } 61 61 62 62 type versionMetadata struct { 63 - Version string `json:"version"` 64 - ArchiveURL string `json:"archive_url"` 65 - Published time.Time `json:"published"` 66 - Pubspec interface{} `json:"pubspec,omitempty"` 63 + Version string `json:"version"` 64 + ArchiveURL string `json:"archive_url"` 65 + Published time.Time `json:"published"` 66 + Pubspec any `json:"pubspec,omitempty"` 67 67 } 68 68 69 69 func packageDescriptorToMetadata(baseURL string, pd *packages_model.PackageDescriptor) *versionMetadata {
+1 -1
routers/api/packages/pypi/pypi.go
··· 37 37 `(?:\+[a-z0-9]+(?:[-_\.][a-z0-9]+)*)?` + // local version 38 38 `\z`) 39 39 40 - func apiError(ctx *context.Context, status int, obj interface{}) { 40 + func apiError(ctx *context.Context, status int, obj any) { 41 41 helper.LogAndProcessError(ctx, status, obj, func(message string) { 42 42 ctx.PlainText(status, message) 43 43 })
+1 -1
routers/api/packages/rpm/rpm.go
··· 25 25 rpm_service "code.gitea.io/gitea/services/packages/rpm" 26 26 ) 27 27 28 - func apiError(ctx *context.Context, status int, obj interface{}) { 28 + func apiError(ctx *context.Context, status int, obj any) { 29 29 helper.LogAndProcessError(ctx, status, obj, func(message string) { 30 30 ctx.PlainText(status, message) 31 31 })
+5 -5
routers/api/packages/rubygems/rubygems.go
··· 21 21 packages_service "code.gitea.io/gitea/services/packages" 22 22 ) 23 23 24 - func apiError(ctx *context.Context, status int, obj interface{}) { 24 + func apiError(ctx *context.Context, status int, obj any) { 25 25 helper.LogAndProcessError(ctx, status, obj, func(message string) { 26 26 ctx.PlainText(status, message) 27 27 }) ··· 65 65 return 66 66 } 67 67 68 - specs := make([]interface{}, 0, len(pds)) 68 + specs := make([]any, 0, len(pds)) 69 69 for _, p := range pds { 70 - specs = append(specs, []interface{}{ 70 + specs = append(specs, []any{ 71 71 p.Package.Name, 72 72 &rubygems_module.RubyUserMarshal{ 73 73 Name: "Gem::Version", ··· 129 129 // create a Ruby Gem::Specification object 130 130 spec := &rubygems_module.RubyUserDef{ 131 131 Name: "Gem::Specification", 132 - Value: []interface{}{ 132 + Value: []any{ 133 133 "3.2.3", // @rubygems_version 134 134 4, // @specification_version, 135 135 pd.Package.Name, ··· 142 142 nil, // @required_ruby_version 143 143 nil, // @required_rubygems_version 144 144 metadata.Platform, // @original_platform 145 - []interface{}{}, // @dependencies 145 + []any{}, // @dependencies 146 146 nil, // rubyforge_project 147 147 "", // @email 148 148 metadata.Authors,
+1 -1
routers/api/packages/swift/swift.go
··· 69 69 } 70 70 71 71 // https://github.com/apple/swift-package-manager/blob/main/Documentation/Registry.md#33-error-handling 72 - func apiError(ctx *context.Context, status int, obj interface{}) { 72 + func apiError(ctx *context.Context, status int, obj any) { 73 73 // https://www.rfc-editor.org/rfc/rfc7807 74 74 type Problem struct { 75 75 Status int `json:"status"`
+1 -1
routers/api/packages/vagrant/vagrant.go
··· 22 22 "github.com/hashicorp/go-version" 23 23 ) 24 24 25 - func apiError(ctx *context.Context, status int, obj interface{}) { 25 + func apiError(ctx *context.Context, status int, obj any) { 26 26 helper.LogAndProcessError(ctx, status, obj, func(message string) { 27 27 ctx.JSON(status, struct { 28 28 Errors []string `json:"errors"`
+2 -2
routers/api/v1/org/team.go
··· 792 792 teams, maxResults, err := organization.SearchTeam(opts) 793 793 if err != nil { 794 794 log.Error("SearchTeam failed: %v", err) 795 - ctx.JSON(http.StatusInternalServerError, map[string]interface{}{ 795 + ctx.JSON(http.StatusInternalServerError, map[string]any{ 796 796 "ok": false, 797 797 "error": "SearchTeam internal failure", 798 798 }) ··· 807 807 808 808 ctx.SetLinkHeader(int(maxResults), listOptions.PageSize) 809 809 ctx.SetTotalCountHeader(maxResults) 810 - ctx.JSON(http.StatusOK, map[string]interface{}{ 810 + ctx.JSON(http.StatusOK, map[string]any{ 811 811 "ok": true, 812 812 "data": apiTeams, 813 813 })
+1 -1
routers/api/v1/repo/repo.go
··· 378 378 ctxUser, err = user_model.GetUserByName(ctx, form.Owner) 379 379 if err != nil { 380 380 if user_model.IsErrUserNotExist(err) { 381 - ctx.JSON(http.StatusNotFound, map[string]interface{}{ 381 + ctx.JSON(http.StatusNotFound, map[string]any{ 382 382 "error": "request owner `" + form.Owner + "` does not exist", 383 383 }) 384 384 return
+7 -7
routers/api/v1/repo/topic.go
··· 63 63 } 64 64 65 65 ctx.SetTotalCountHeader(total) 66 - ctx.JSON(http.StatusOK, map[string]interface{}{ 66 + ctx.JSON(http.StatusOK, map[string]any{ 67 67 "topics": topicNames, 68 68 }) 69 69 } ··· 101 101 validTopics, invalidTopics := repo_model.SanitizeAndValidateTopics(topicNames) 102 102 103 103 if len(validTopics) > 25 { 104 - ctx.JSON(http.StatusUnprocessableEntity, map[string]interface{}{ 104 + ctx.JSON(http.StatusUnprocessableEntity, map[string]any{ 105 105 "invalidTopics": nil, 106 106 "message": "Exceeding maximum number of topics per repo", 107 107 }) ··· 109 109 } 110 110 111 111 if len(invalidTopics) > 0 { 112 - ctx.JSON(http.StatusUnprocessableEntity, map[string]interface{}{ 112 + ctx.JSON(http.StatusUnprocessableEntity, map[string]any{ 113 113 "invalidTopics": invalidTopics, 114 114 "message": "Topic names are invalid", 115 115 }) ··· 158 158 topicName := strings.TrimSpace(strings.ToLower(ctx.Params(":topic"))) 159 159 160 160 if !repo_model.ValidateTopic(topicName) { 161 - ctx.JSON(http.StatusUnprocessableEntity, map[string]interface{}{ 161 + ctx.JSON(http.StatusUnprocessableEntity, map[string]any{ 162 162 "invalidTopics": topicName, 163 163 "message": "Topic name is invalid", 164 164 }) ··· 175 175 return 176 176 } 177 177 if count >= 25 { 178 - ctx.JSON(http.StatusUnprocessableEntity, map[string]interface{}{ 178 + ctx.JSON(http.StatusUnprocessableEntity, map[string]any{ 179 179 "message": "Exceeding maximum allowed topics per repo.", 180 180 }) 181 181 return ··· 223 223 topicName := strings.TrimSpace(strings.ToLower(ctx.Params(":topic"))) 224 224 225 225 if !repo_model.ValidateTopic(topicName) { 226 - ctx.JSON(http.StatusUnprocessableEntity, map[string]interface{}{ 226 + ctx.JSON(http.StatusUnprocessableEntity, map[string]any{ 227 227 "invalidTopics": topicName, 228 228 "message": "Topic name is invalid", 229 229 }) ··· 289 289 } 290 290 291 291 ctx.SetTotalCountHeader(total) 292 - ctx.JSON(http.StatusOK, map[string]interface{}{ 292 + ctx.JSON(http.StatusOK, map[string]any{ 293 293 "topics": topicResponses, 294 294 }) 295 295 }
+2 -2
routers/api/v1/user/user.go
··· 62 62 ListOptions: listOptions, 63 63 }) 64 64 if err != nil { 65 - ctx.JSON(http.StatusInternalServerError, map[string]interface{}{ 65 + ctx.JSON(http.StatusInternalServerError, map[string]any{ 66 66 "ok": false, 67 67 "error": err.Error(), 68 68 }) ··· 72 72 ctx.SetLinkHeader(int(maxResults), listOptions.PageSize) 73 73 ctx.SetTotalCountHeader(maxResults) 74 74 75 - ctx.JSON(http.StatusOK, map[string]interface{}{ 75 + ctx.JSON(http.StatusOK, map[string]any{ 76 76 "ok": true, 77 77 "data": convert.ToUsers(ctx, ctx.Doer, users), 78 78 })
+1 -1
routers/private/manager_process.go
··· 49 49 } 50 50 51 51 if json { 52 - ctx.JSON(http.StatusOK, map[string]interface{}{ 52 + ctx.JSON(http.StatusOK, map[string]any{ 53 53 "TotalNumberOfGoroutines": goroutineCount, 54 54 "TotalNumberOfProcesses": processCount, 55 55 "Processes": processes,
+3 -3
routers/web/admin/auths.go
··· 60 60 61 61 type dropdownItem struct { 62 62 Name string 63 - Type interface{} 63 + Type any 64 64 } 65 65 66 66 var ( ··· 454 454 } else { 455 455 ctx.Flash.Error(fmt.Sprintf("auth_service.DeleteSource: %v", err)) 456 456 } 457 - ctx.JSON(http.StatusOK, map[string]interface{}{ 457 + ctx.JSON(http.StatusOK, map[string]any{ 458 458 "redirect": setting.AppSubURL + "/admin/auths/" + url.PathEscape(ctx.Params(":authid")), 459 459 }) 460 460 return ··· 462 462 log.Trace("Authentication deleted by admin(%s): %d", ctx.Doer.Name, source.ID) 463 463 464 464 ctx.Flash.Success(ctx.Tr("admin.auths.deletion_success")) 465 - ctx.JSON(http.StatusOK, map[string]interface{}{ 465 + ctx.JSON(http.StatusOK, map[string]any{ 466 466 "redirect": setting.AppSubURL + "/admin/auths", 467 467 }) 468 468 }
+1 -1
routers/web/admin/config.go
··· 207 207 return 208 208 } 209 209 210 - ctx.JSON(http.StatusOK, map[string]interface{}{ 210 + ctx.JSON(http.StatusOK, map[string]any{ 211 211 "version": version + 1, 212 212 }) 213 213 }
+3 -3
routers/web/admin/hooks.go
··· 26 26 ctx.Data["PageIsAdminSystemHooks"] = true 27 27 ctx.Data["PageIsAdminDefaultHooks"] = true 28 28 29 - def := make(map[string]interface{}, len(ctx.Data)) 30 - sys := make(map[string]interface{}, len(ctx.Data)) 29 + def := make(map[string]any, len(ctx.Data)) 30 + sys := make(map[string]any, len(ctx.Data)) 31 31 for k, v := range ctx.Data { 32 32 def[k] = v 33 33 sys[k] = v ··· 67 67 ctx.Flash.Success(ctx.Tr("repo.settings.webhook_deletion_success")) 68 68 } 69 69 70 - ctx.JSON(http.StatusOK, map[string]interface{}{ 70 + ctx.JSON(http.StatusOK, map[string]any{ 71 71 "redirect": setting.AppSubURL + "/admin/hooks", 72 72 }) 73 73 }
+1 -1
routers/web/admin/packages.go
··· 97 97 } 98 98 99 99 ctx.Flash.Success(ctx.Tr("packages.settings.delete.success")) 100 - ctx.JSON(http.StatusOK, map[string]interface{}{ 100 + ctx.JSON(http.StatusOK, map[string]any{ 101 101 "redirect": setting.AppSubURL + "/admin/packages?page=" + url.QueryEscape(ctx.FormString("page")) + "&q=" + url.QueryEscape(ctx.FormString("q")) + "&type=" + url.QueryEscape(ctx.FormString("type")), 102 102 }) 103 103 }
+1 -1
routers/web/admin/repos.go
··· 58 58 log.Trace("Repository deleted: %s", repo.FullName()) 59 59 60 60 ctx.Flash.Success(ctx.Tr("repo.settings.deletion_success")) 61 - ctx.JSON(http.StatusOK, map[string]interface{}{ 61 + ctx.JSON(http.StatusOK, map[string]any{ 62 62 "redirect": setting.AppSubURL + "/admin/repos?page=" + url.QueryEscape(ctx.FormString("page")) + "&sort=" + url.QueryEscape(ctx.FormString("sort")), 63 63 }) 64 64 }
+1 -1
routers/web/admin/stacktrace.go
··· 42 42 func StacktraceCancel(ctx *context.Context) { 43 43 pid := ctx.Params("pid") 44 44 process.GetManager().Cancel(process.IDType(pid)) 45 - ctx.JSON(http.StatusOK, map[string]interface{}{ 45 + ctx.JSON(http.StatusOK, map[string]any{ 46 46 "redirect": setting.AppSubURL + "/admin/monitor/stacktrace", 47 47 }) 48 48 }
+1 -1
routers/web/admin/users.go
··· 56 56 sortType = explore.UserSearchDefaultAdminSort 57 57 ctx.SetFormString("sort", sortType) 58 58 } 59 - ctx.PageData["adminUserListSearchForm"] = map[string]interface{}{ 59 + ctx.PageData["adminUserListSearchForm"] = map[string]any{ 60 60 "StatusFilterMap": statusFilterMap, 61 61 "SortType": sortType, 62 62 }
+7 -7
routers/web/auth/auth.go
··· 78 78 79 79 isSucceed = true 80 80 81 - if err := updateSession(ctx, nil, map[string]interface{}{ 81 + if err := updateSession(ctx, nil, map[string]any{ 82 82 // Set session IDs 83 83 "uid": u.ID, 84 84 "uname": u.Name, ··· 255 255 return 256 256 } 257 257 258 - updates := map[string]interface{}{ 258 + updates := map[string]any{ 259 259 // User will need to use 2FA TOTP or WebAuthn, save data 260 260 "twofaUid": u.ID, 261 261 "twofaRemember": form.Remember, ··· 305 305 "twofaUid", 306 306 "twofaRemember", 307 307 "linkAccount", 308 - }, map[string]interface{}{ 308 + }, map[string]any{ 309 309 "uid": u.ID, 310 310 "uname": u.Name, 311 311 }); err != nil { ··· 476 476 477 477 // createAndHandleCreatedUser calls createUserInContext and 478 478 // then handleUserCreated. 479 - func createAndHandleCreatedUser(ctx *context.Context, tpl base.TplName, form interface{}, u *user_model.User, overwrites *user_model.CreateUserOverwriteOptions, gothUser *goth.User, allowLink bool) bool { 479 + func createAndHandleCreatedUser(ctx *context.Context, tpl base.TplName, form any, u *user_model.User, overwrites *user_model.CreateUserOverwriteOptions, gothUser *goth.User, allowLink bool) bool { 480 480 if !createUserInContext(ctx, tpl, form, u, overwrites, gothUser, allowLink) { 481 481 return false 482 482 } ··· 485 485 486 486 // createUserInContext creates a user and handles errors within a given context. 487 487 // Optionally a template can be specified. 488 - func createUserInContext(ctx *context.Context, tpl base.TplName, form interface{}, u *user_model.User, overwrites *user_model.CreateUserOverwriteOptions, gothUser *goth.User, allowLink bool) (ok bool) { 488 + func createUserInContext(ctx *context.Context, tpl base.TplName, form any, u *user_model.User, overwrites *user_model.CreateUserOverwriteOptions, gothUser *goth.User, allowLink bool) (ok bool) { 489 489 if err := user_model.CreateUser(u, overwrites); err != nil { 490 490 if allowLink && (user_model.IsErrUserAlreadyExist(err) || user_model.IsErrEmailAlreadyUsed(err)) { 491 491 if setting.OAuth2Client.AccountLinking == setting.OAuth2AccountLinkingAuto { ··· 707 707 708 708 log.Trace("User activated: %s", user.Name) 709 709 710 - if err := updateSession(ctx, nil, map[string]interface{}{ 710 + if err := updateSession(ctx, nil, map[string]any{ 711 711 "uid": user.ID, 712 712 "uname": user.Name, 713 713 }); err != nil { ··· 760 760 ctx.Redirect(setting.AppSubURL + "/user/settings/account") 761 761 } 762 762 763 - func updateSession(ctx *context.Context, deletes []string, updates map[string]interface{}) error { 763 + func updateSession(ctx *context.Context, deletes []string, updates map[string]any) error { 764 764 if _, err := session.RegenerateSession(ctx.Resp, ctx.Req); err != nil { 765 765 return fmt.Errorf("regenerate session: %w", err) 766 766 }
+1 -1
routers/web/auth/linkaccount.go
··· 174 174 return 175 175 } 176 176 177 - if err := updateSession(ctx, nil, map[string]interface{}{ 177 + if err := updateSession(ctx, nil, map[string]any{ 178 178 // User needs to use 2FA, save data and redirect to 2FA page. 179 179 "twofaUid": u.ID, 180 180 "twofaRemember": remember,
+5 -5
routers/web/auth/oauth.go
··· 1008 1008 handleOAuth2SignIn(ctx, authSource, u, gothUser) 1009 1009 } 1010 1010 1011 - func claimValueToStringSet(claimValue interface{}) container.Set[string] { 1011 + func claimValueToStringSet(claimValue any) container.Set[string] { 1012 1012 var groups []string 1013 1013 1014 1014 switch rawGroup := claimValue.(type) { 1015 1015 case []string: 1016 1016 groups = rawGroup 1017 - case []interface{}: 1017 + case []any: 1018 1018 for _, group := range rawGroup { 1019 1019 groups = append(groups, fmt.Sprintf("%s", group)) 1020 1020 } ··· 1067 1067 } 1068 1068 1069 1069 func showLinkingLogin(ctx *context.Context, gothUser goth.User) { 1070 - if err := updateSession(ctx, nil, map[string]interface{}{ 1070 + if err := updateSession(ctx, nil, map[string]any{ 1071 1071 "linkAccountGothUser": gothUser, 1072 1072 }); err != nil { 1073 1073 ctx.ServerError("updateSession", err) ··· 1119 1119 // If this user is enrolled in 2FA and this source doesn't override it, 1120 1120 // we can't sign the user in just yet. Instead, redirect them to the 2FA authentication page. 1121 1121 if !needs2FA { 1122 - if err := updateSession(ctx, nil, map[string]interface{}{ 1122 + if err := updateSession(ctx, nil, map[string]any{ 1123 1123 "uid": u.ID, 1124 1124 "uname": u.Name, 1125 1125 }); err != nil { ··· 1189 1189 } 1190 1190 } 1191 1191 1192 - if err := updateSession(ctx, nil, map[string]interface{}{ 1192 + if err := updateSession(ctx, nil, map[string]any{ 1193 1193 // User needs to use 2FA, save data and redirect to 2FA page. 1194 1194 "twofaUid": u.ID, 1195 1195 "twofaRemember": false,
+1 -1
routers/web/auth/oauth_test.go
··· 26 26 assert.Nil(t, terr) 27 27 assert.NotNil(t, response) 28 28 29 - parsedToken, err := jwt.ParseWithClaims(response.IDToken, &oauth2.OIDCToken{}, func(token *jwt.Token) (interface{}, error) { 29 + parsedToken, err := jwt.ParseWithClaims(response.IDToken, &oauth2.OIDCToken{}, func(token *jwt.Token) (any, error) { 30 30 assert.NotNil(t, token.Method) 31 31 assert.Equal(t, signingKey.SigningMethod().Alg(), token.Method.Alg()) 32 32 return signingKey.VerifyKey(), nil
+1 -1
routers/web/auth/openid.go
··· 230 230 if u != nil { 231 231 nickname = u.LowerName 232 232 } 233 - if err := updateSession(ctx, nil, map[string]interface{}{ 233 + if err := updateSession(ctx, nil, map[string]any{ 234 234 "openid_verified_uri": id, 235 235 "openid_determined_email": email, 236 236 "openid_determined_username": nickname,
+1 -1
routers/web/explore/topic.go
··· 35 35 } 36 36 37 37 ctx.SetTotalCountHeader(total) 38 - ctx.JSON(http.StatusOK, map[string]interface{}{ 38 + ctx.JSON(http.StatusOK, map[string]any{ 39 39 "topics": topicResponses, 40 40 }) 41 41 }
+5 -5
routers/web/org/members.go
··· 101 101 err = models.RemoveOrgUser(org.ID, uid) 102 102 if organization.IsErrLastOrgOwner(err) { 103 103 ctx.Flash.Error(ctx.Tr("form.last_org_owner")) 104 - ctx.JSON(http.StatusOK, map[string]interface{}{ 104 + ctx.JSON(http.StatusOK, map[string]any{ 105 105 "redirect": ctx.Org.OrgLink + "/members", 106 106 }) 107 107 return ··· 110 110 err = models.RemoveOrgUser(org.ID, ctx.Doer.ID) 111 111 if err == nil { 112 112 ctx.Flash.Success(ctx.Tr("form.organization_leave_success", org.DisplayName())) 113 - ctx.JSON(http.StatusOK, map[string]interface{}{ 113 + ctx.JSON(http.StatusOK, map[string]any{ 114 114 "redirect": "", // keep the user stay on current page, in case they want to do other operations. 115 115 }) 116 116 } else if organization.IsErrLastOrgOwner(err) { 117 117 ctx.Flash.Error(ctx.Tr("form.last_org_owner")) 118 - ctx.JSON(http.StatusOK, map[string]interface{}{ 118 + ctx.JSON(http.StatusOK, map[string]any{ 119 119 "redirect": ctx.Org.OrgLink + "/members", 120 120 }) 121 121 } else { ··· 126 126 127 127 if err != nil { 128 128 log.Error("Action(%s): %v", ctx.Params(":action"), err) 129 - ctx.JSON(http.StatusOK, map[string]interface{}{ 129 + ctx.JSON(http.StatusOK, map[string]any{ 130 130 "ok": false, 131 131 "err": err.Error(), 132 132 }) ··· 138 138 redirect = setting.AppSubURL + "/" 139 139 } 140 140 141 - ctx.JSON(http.StatusOK, map[string]interface{}{ 141 + ctx.JSON(http.StatusOK, map[string]any{ 142 142 "redirect": redirect, 143 143 }) 144 144 }
+1 -1
routers/web/org/org_labels.go
··· 90 90 ctx.Flash.Success(ctx.Tr("repo.issues.label_deletion_success")) 91 91 } 92 92 93 - ctx.JSON(http.StatusOK, map[string]interface{}{ 93 + ctx.JSON(http.StatusOK, map[string]any{ 94 94 "redirect": ctx.Org.OrgLink + "/settings/labels", 95 95 }) 96 96 }
+8 -8
routers/web/org/projects.go
··· 218 218 ctx.Flash.Success(ctx.Tr("repo.projects.deletion_success")) 219 219 } 220 220 221 - ctx.JSON(http.StatusOK, map[string]interface{}{ 221 + ctx.JSON(http.StatusOK, map[string]any{ 222 222 "redirect": ctx.ContextUser.HomeLink() + "/-/projects", 223 223 }) 224 224 } ··· 449 449 } 450 450 } 451 451 452 - ctx.JSON(http.StatusOK, map[string]interface{}{ 452 + ctx.JSON(http.StatusOK, map[string]any{ 453 453 "ok": true, 454 454 }) 455 455 } ··· 497 497 return 498 498 } 499 499 500 - ctx.JSON(http.StatusOK, map[string]interface{}{ 500 + ctx.JSON(http.StatusOK, map[string]any{ 501 501 "ok": true, 502 502 }) 503 503 } ··· 526 526 return 527 527 } 528 528 529 - ctx.JSON(http.StatusOK, map[string]interface{}{ 529 + ctx.JSON(http.StatusOK, map[string]any{ 530 530 "ok": true, 531 531 }) 532 532 } ··· 594 594 return 595 595 } 596 596 597 - ctx.JSON(http.StatusOK, map[string]interface{}{ 597 + ctx.JSON(http.StatusOK, map[string]any{ 598 598 "ok": true, 599 599 }) 600 600 } ··· 611 611 return 612 612 } 613 613 614 - ctx.JSON(http.StatusOK, map[string]interface{}{ 614 + ctx.JSON(http.StatusOK, map[string]any{ 615 615 "ok": true, 616 616 }) 617 617 } ··· 628 628 return 629 629 } 630 630 631 - ctx.JSON(http.StatusOK, map[string]interface{}{ 631 + ctx.JSON(http.StatusOK, map[string]any{ 632 632 "ok": true, 633 633 }) 634 634 } ··· 730 730 return 731 731 } 732 732 733 - ctx.JSON(http.StatusOK, map[string]interface{}{ 733 + ctx.JSON(http.StatusOK, map[string]any{ 734 734 "ok": true, 735 735 }) 736 736 }
+1 -1
routers/web/org/setting.go
··· 224 224 ctx.Flash.Success(ctx.Tr("repo.settings.webhook_deletion_success")) 225 225 } 226 226 227 - ctx.JSON(http.StatusOK, map[string]interface{}{ 227 + ctx.JSON(http.StatusOK, map[string]any{ 228 228 "redirect": ctx.Org.OrgLink + "/settings/hooks", 229 229 }) 230 230 }
+10 -10
routers/web/org/teams.go
··· 79 79 ctx.Flash.Error(ctx.Tr("form.last_org_owner")) 80 80 } else { 81 81 log.Error("Action(%s): %v", ctx.Params(":action"), err) 82 - ctx.JSON(http.StatusOK, map[string]interface{}{ 82 + ctx.JSON(http.StatusOK, map[string]any{ 83 83 "ok": false, 84 84 "err": err.Error(), 85 85 }) ··· 95 95 redirect = setting.AppSubURL + "/" 96 96 } 97 97 ctx.JSON(http.StatusOK, 98 - map[string]interface{}{ 98 + map[string]any{ 99 99 "redirect": redirect, 100 100 }) 101 101 return ··· 117 117 ctx.Flash.Error(ctx.Tr("form.last_org_owner")) 118 118 } else { 119 119 log.Error("Action(%s): %v", ctx.Params(":action"), err) 120 - ctx.JSON(http.StatusOK, map[string]interface{}{ 120 + ctx.JSON(http.StatusOK, map[string]any{ 121 121 "ok": false, 122 122 "err": err.Error(), 123 123 }) ··· 125 125 } 126 126 } 127 127 ctx.JSON(http.StatusOK, 128 - map[string]interface{}{ 128 + map[string]any{ 129 129 "redirect": ctx.Org.OrgLink + "/teams/" + url.PathEscape(ctx.Org.Team.LowerName), 130 130 }) 131 131 return ··· 199 199 ctx.Flash.Error(ctx.Tr("form.last_org_owner")) 200 200 } else { 201 201 log.Error("Action(%s): %v", ctx.Params(":action"), err) 202 - ctx.JSON(http.StatusOK, map[string]interface{}{ 202 + ctx.JSON(http.StatusOK, map[string]any{ 203 203 "ok": false, 204 204 "err": err.Error(), 205 205 }) ··· 256 256 } 257 257 258 258 if action == "addall" || action == "removeall" { 259 - ctx.JSON(http.StatusOK, map[string]interface{}{ 259 + ctx.JSON(http.StatusOK, map[string]any{ 260 260 "redirect": ctx.Org.OrgLink + "/teams/" + url.PathEscape(ctx.Org.Team.LowerName) + "/repositories", 261 261 }) 262 262 return ··· 414 414 teams, maxResults, err := org_model.SearchTeam(opts) 415 415 if err != nil { 416 416 log.Error("SearchTeam failed: %v", err) 417 - ctx.JSON(http.StatusInternalServerError, map[string]interface{}{ 417 + ctx.JSON(http.StatusInternalServerError, map[string]any{ 418 418 "ok": false, 419 419 "error": "SearchTeam internal failure", 420 420 }) ··· 424 424 apiTeams, err := convert.ToTeams(ctx, teams, false) 425 425 if err != nil { 426 426 log.Error("convert ToTeams failed: %v", err) 427 - ctx.JSON(http.StatusInternalServerError, map[string]interface{}{ 427 + ctx.JSON(http.StatusInternalServerError, map[string]any{ 428 428 "ok": false, 429 429 "error": "SearchTeam failed to get units", 430 430 }) ··· 432 432 } 433 433 434 434 ctx.SetTotalCountHeader(maxResults) 435 - ctx.JSON(http.StatusOK, map[string]interface{}{ 435 + ctx.JSON(http.StatusOK, map[string]any{ 436 436 "ok": true, 437 437 "data": apiTeams, 438 438 }) ··· 530 530 ctx.Flash.Success(ctx.Tr("org.teams.delete_team_success")) 531 531 } 532 532 533 - ctx.JSON(http.StatusOK, map[string]interface{}{ 533 + ctx.JSON(http.StatusOK, map[string]any{ 534 534 "redirect": ctx.Org.OrgLink + "/teams", 535 535 }) 536 536 }
+2 -2
routers/web/repo/branch.go
··· 162 162 } 163 163 164 164 func redirect(ctx *context.Context) { 165 - ctx.JSON(http.StatusOK, map[string]interface{}{ 165 + ctx.JSON(http.StatusOK, map[string]any{ 166 166 "redirect": ctx.Repo.RepoLink + "/branches?page=" + url.QueryEscape(ctx.FormString("page")), 167 167 }) 168 168 } ··· 223 223 if len(e.Message) == 0 { 224 224 ctx.Flash.Error(ctx.Tr("repo.editor.push_rejected_no_message")) 225 225 } else { 226 - flashError, err := ctx.RenderToString(tplAlertDetails, map[string]interface{}{ 226 + flashError, err := ctx.RenderToString(tplAlertDetails, map[string]any{ 227 227 "Message": ctx.Tr("repo.editor.push_rejected"), 228 228 "Summary": ctx.Tr("repo.editor.push_rejected_summary"), 229 229 "Details": utils.SanitizeFlashErrorString(e.Message),
+4 -4
routers/web/repo/editor.go
··· 344 344 if len(errPushRej.Message) == 0 { 345 345 ctx.RenderWithErr(ctx.Tr("repo.editor.push_rejected_no_message"), tplEditFile, &form) 346 346 } else { 347 - flashError, err := ctx.RenderToString(tplAlertDetails, map[string]interface{}{ 347 + flashError, err := ctx.RenderToString(tplAlertDetails, map[string]any{ 348 348 "Message": ctx.Tr("repo.editor.push_rejected"), 349 349 "Summary": ctx.Tr("repo.editor.push_rejected_summary"), 350 350 "Details": utils.SanitizeFlashErrorString(errPushRej.Message), ··· 356 356 ctx.RenderWithErr(flashError, tplEditFile, &form) 357 357 } 358 358 } else { 359 - flashError, err := ctx.RenderToString(tplAlertDetails, map[string]interface{}{ 359 + flashError, err := ctx.RenderToString(tplAlertDetails, map[string]any{ 360 360 "Message": ctx.Tr("repo.editor.fail_to_update_file", form.TreePath), 361 361 "Summary": ctx.Tr("repo.editor.fail_to_update_file_summary"), 362 362 "Details": utils.SanitizeFlashErrorString(err.Error()), ··· 543 543 if len(errPushRej.Message) == 0 { 544 544 ctx.RenderWithErr(ctx.Tr("repo.editor.push_rejected_no_message"), tplDeleteFile, &form) 545 545 } else { 546 - flashError, err := ctx.RenderToString(tplAlertDetails, map[string]interface{}{ 546 + flashError, err := ctx.RenderToString(tplAlertDetails, map[string]any{ 547 547 "Message": ctx.Tr("repo.editor.push_rejected"), 548 548 "Summary": ctx.Tr("repo.editor.push_rejected_summary"), 549 549 "Details": utils.SanitizeFlashErrorString(errPushRej.Message), ··· 743 743 if len(errPushRej.Message) == 0 { 744 744 ctx.RenderWithErr(ctx.Tr("repo.editor.push_rejected_no_message"), tplUploadFile, &form) 745 745 } else { 746 - flashError, err := ctx.RenderToString(tplAlertDetails, map[string]interface{}{ 746 + flashError, err := ctx.RenderToString(tplAlertDetails, map[string]any{ 747 747 "Message": ctx.Tr("repo.editor.push_rejected"), 748 748 "Summary": ctx.Tr("repo.editor.push_rejected_summary"), 749 749 "Details": utils.SanitizeFlashErrorString(errPushRej.Message),
+18 -18
routers/web/repo/issue.go
··· 952 952 lines = append(lines, fmt.Sprintf("%s: %v", file, errs[file])) 953 953 } 954 954 955 - flashError, err := ctx.RenderToString(tplAlertDetails, map[string]interface{}{ 955 + flashError, err := ctx.RenderToString(tplAlertDetails, map[string]any{ 956 956 "Message": ctx.Tr("repo.issues.choose.ignore_invalid_templates"), 957 957 "Summary": ctx.Tr("repo.issues.choose.invalid_templates", len(errs)), 958 958 "Details": utils.SanitizeFlashErrorString(strings.Join(lines, "\n")), ··· 2081 2081 return 2082 2082 } 2083 2083 2084 - ctx.JSON(http.StatusOK, map[string]interface{}{ 2084 + ctx.JSON(http.StatusOK, map[string]any{ 2085 2085 "title": issue.Title, 2086 2086 }) 2087 2087 } ··· 2105 2105 return 2106 2106 } 2107 2107 2108 - ctx.JSON(http.StatusOK, map[string]interface{}{ 2108 + ctx.JSON(http.StatusOK, map[string]any{ 2109 2109 "ref": ref, 2110 2110 }) 2111 2111 } ··· 2146 2146 return 2147 2147 } 2148 2148 2149 - ctx.JSON(http.StatusOK, map[string]interface{}{ 2149 + ctx.JSON(http.StatusOK, map[string]any{ 2150 2150 "content": content, 2151 2151 "attachments": attachmentsHTML(ctx, issue.Attachments, issue.Content), 2152 2152 }) ··· 2206 2206 } 2207 2207 } 2208 2208 2209 - ctx.JSON(http.StatusOK, map[string]interface{}{ 2209 + ctx.JSON(http.StatusOK, map[string]any{ 2210 2210 "ok": true, 2211 2211 }) 2212 2212 } ··· 2252 2252 } 2253 2253 } 2254 2254 } 2255 - ctx.JSON(http.StatusOK, map[string]interface{}{ 2255 + ctx.JSON(http.StatusOK, map[string]any{ 2256 2256 "ok": true, 2257 2257 }) 2258 2258 } ··· 2377 2377 } 2378 2378 } 2379 2379 2380 - ctx.JSON(http.StatusOK, map[string]interface{}{ 2380 + ctx.JSON(http.StatusOK, map[string]any{ 2381 2381 "ok": true, 2382 2382 }) 2383 2383 } ··· 2763 2763 if issue.IsClosed != isClosed { 2764 2764 if err := issue_service.ChangeStatus(issue, ctx.Doer, "", isClosed); err != nil { 2765 2765 if issues_model.IsErrDependenciesLeft(err) { 2766 - ctx.JSON(http.StatusPreconditionFailed, map[string]interface{}{ 2766 + ctx.JSON(http.StatusPreconditionFailed, map[string]any{ 2767 2767 "error": ctx.Tr("repo.issues.dependency.issue_batch_close_blocked", issue.Index), 2768 2768 }) 2769 2769 return ··· 2978 2978 oldContent := comment.Content 2979 2979 comment.Content = ctx.FormString("content") 2980 2980 if len(comment.Content) == 0 { 2981 - ctx.JSON(http.StatusOK, map[string]interface{}{ 2981 + ctx.JSON(http.StatusOK, map[string]any{ 2982 2982 "content": "", 2983 2983 }) 2984 2984 return ··· 3012 3012 return 3013 3013 } 3014 3014 3015 - ctx.JSON(http.StatusOK, map[string]interface{}{ 3015 + ctx.JSON(http.StatusOK, map[string]any{ 3016 3016 "content": content, 3017 3017 "attachments": attachmentsHTML(ctx, comment.Attachments, comment.Content), 3018 3018 }) ··· 3122 3122 } 3123 3123 3124 3124 if len(issue.Reactions) == 0 { 3125 - ctx.JSON(http.StatusOK, map[string]interface{}{ 3125 + ctx.JSON(http.StatusOK, map[string]any{ 3126 3126 "empty": true, 3127 3127 "html": "", 3128 3128 }) 3129 3129 return 3130 3130 } 3131 3131 3132 - html, err := ctx.RenderToString(tplReactions, map[string]interface{}{ 3132 + html, err := ctx.RenderToString(tplReactions, map[string]any{ 3133 3133 "ctxData": ctx.Data, 3134 3134 "ActionURL": fmt.Sprintf("%s/issues/%d/reactions", ctx.Repo.RepoLink, issue.Index), 3135 3135 "Reactions": issue.Reactions.GroupByType(), ··· 3138 3138 ctx.ServerError("ChangeIssueReaction.HTMLString", err) 3139 3139 return 3140 3140 } 3141 - ctx.JSON(http.StatusOK, map[string]interface{}{ 3141 + ctx.JSON(http.StatusOK, map[string]any{ 3142 3142 "html": html, 3143 3143 }) 3144 3144 } ··· 3224 3224 } 3225 3225 3226 3226 if len(comment.Reactions) == 0 { 3227 - ctx.JSON(http.StatusOK, map[string]interface{}{ 3227 + ctx.JSON(http.StatusOK, map[string]any{ 3228 3228 "empty": true, 3229 3229 "html": "", 3230 3230 }) 3231 3231 return 3232 3232 } 3233 3233 3234 - html, err := ctx.RenderToString(tplReactions, map[string]interface{}{ 3234 + html, err := ctx.RenderToString(tplReactions, map[string]any{ 3235 3235 "ctxData": ctx.Data, 3236 3236 "ActionURL": fmt.Sprintf("%s/comments/%d/reactions", ctx.Repo.RepoLink, comment.ID), 3237 3237 "Reactions": comment.Reactions.GroupByType(), ··· 3240 3240 ctx.ServerError("ChangeCommentReaction.HTMLString", err) 3241 3241 return 3242 3242 } 3243 - ctx.JSON(http.StatusOK, map[string]interface{}{ 3243 + ctx.JSON(http.StatusOK, map[string]any{ 3244 3244 "html": html, 3245 3245 }) 3246 3246 } ··· 3313 3313 ctx.JSON(http.StatusOK, attachments) 3314 3314 } 3315 3315 3316 - func updateAttachments(ctx *context.Context, item interface{}, files []string) error { 3316 + func updateAttachments(ctx *context.Context, item any, files []string) error { 3317 3317 var attachments []*repo_model.Attachment 3318 3318 switch content := item.(type) { 3319 3319 case *issues_model.Issue: ··· 3357 3357 } 3358 3358 3359 3359 func attachmentsHTML(ctx *context.Context, attachments []*repo_model.Attachment, content string) string { 3360 - attachHTML, err := ctx.RenderToString(tplAttachment, map[string]interface{}{ 3360 + attachHTML, err := ctx.RenderToString(tplAttachment, map[string]any{ 3361 3361 "ctxData": ctx.Data, 3362 3362 "Attachments": attachments, 3363 3363 "Content": content,
+9 -9
routers/web/repo/issue_content_history.go
··· 29 29 } 30 30 31 31 editedHistoryCountMap, _ := issues_model.QueryIssueContentHistoryEditedCountMap(ctx, issue.ID) 32 - ctx.JSON(http.StatusOK, map[string]interface{}{ 33 - "i18n": map[string]interface{}{ 32 + ctx.JSON(http.StatusOK, map[string]any{ 33 + "i18n": map[string]any{ 34 34 "textEdited": ctx.Tr("repo.issues.content_history.edited"), 35 35 "textDeleteFromHistory": ctx.Tr("repo.issues.content_history.delete_from_history"), 36 36 "textDeleteFromHistoryConfirm": ctx.Tr("repo.issues.content_history.delete_from_history_confirm"), ··· 53 53 // render history list to HTML for frontend dropdown items: (name, value) 54 54 // name is HTML of "avatar + userName + userAction + timeSince" 55 55 // value is historyId 56 - var results []map[string]interface{} 56 + var results []map[string]any 57 57 for _, item := range items { 58 58 var actionText string 59 59 if item.IsDeleted { ··· 76 76 avatarHTML := string(templates.AvatarHTML(src, 28, class, username)) 77 77 timeSinceText := string(timeutil.TimeSinceUnix(item.EditedUnix, ctx.Locale)) 78 78 79 - results = append(results, map[string]interface{}{ 79 + results = append(results, map[string]any{ 80 80 "name": avatarHTML + "<strong>" + name + "</strong> " + actionText + " " + timeSinceText, 81 81 "value": item.HistoryID, 82 82 }) 83 83 } 84 84 85 - ctx.JSON(http.StatusOK, map[string]interface{}{ 85 + ctx.JSON(http.StatusOK, map[string]any{ 86 86 "results": results, 87 87 }) 88 88 } ··· 120 120 historyID := ctx.FormInt64("history_id") 121 121 history, prevHistory, err := issues_model.GetIssueContentHistoryAndPrev(ctx, historyID) 122 122 if err != nil { 123 - ctx.JSON(http.StatusNotFound, map[string]interface{}{ 123 + ctx.JSON(http.StatusNotFound, map[string]any{ 124 124 "message": "Can not find the content history", 125 125 }) 126 126 return ··· 168 168 } 169 169 diffHTMLBuf.WriteString("</pre>") 170 170 171 - ctx.JSON(http.StatusOK, map[string]interface{}{ 171 + ctx.JSON(http.StatusOK, map[string]any{ 172 172 "canSoftDelete": canSoftDeleteContentHistory(ctx, issue, comment, history), 173 173 "historyId": historyID, 174 174 "prevHistoryId": prevHistoryID, ··· 202 202 203 203 canSoftDelete := canSoftDeleteContentHistory(ctx, issue, comment, history) 204 204 if !canSoftDelete { 205 - ctx.JSON(http.StatusForbidden, map[string]interface{}{ 205 + ctx.JSON(http.StatusForbidden, map[string]any{ 206 206 "message": "Can not delete the content history", 207 207 }) 208 208 return ··· 210 210 211 211 err = issues_model.SoftDeleteIssueContentHistory(ctx, historyID) 212 212 log.Debug("soft delete issue content history. issue=%d, comment=%d, history=%d", issue.ID, commentID, historyID) 213 - ctx.JSON(http.StatusOK, map[string]interface{}{ 213 + ctx.JSON(http.StatusOK, map[string]any{ 214 214 "ok": err == nil, 215 215 }) 216 216 }
+2 -2
routers/web/repo/issue_label.go
··· 157 157 ctx.Flash.Success(ctx.Tr("repo.issues.label_deletion_success")) 158 158 } 159 159 160 - ctx.JSON(http.StatusOK, map[string]interface{}{ 160 + ctx.JSON(http.StatusOK, map[string]any{ 161 161 "redirect": ctx.Repo.RepoLink + "/labels", 162 162 }) 163 163 } ··· 226 226 return 227 227 } 228 228 229 - ctx.JSON(http.StatusOK, map[string]interface{}{ 229 + ctx.JSON(http.StatusOK, map[string]any{ 230 230 "ok": true, 231 231 }) 232 232 }
+1 -1
routers/web/repo/milestone.go
··· 256 256 ctx.Flash.Success(ctx.Tr("repo.milestones.deletion_success")) 257 257 } 258 258 259 - ctx.JSON(http.StatusOK, map[string]interface{}{ 259 + ctx.JSON(http.StatusOK, map[string]any{ 260 260 "redirect": ctx.Repo.RepoLink + "/milestones", 261 261 }) 262 262 }
+8 -8
routers/web/repo/projects.go
··· 203 203 ctx.Flash.Success(ctx.Tr("repo.projects.deletion_success")) 204 204 } 205 205 206 - ctx.JSON(http.StatusOK, map[string]interface{}{ 206 + ctx.JSON(http.StatusOK, map[string]any{ 207 207 "redirect": ctx.Repo.RepoLink + "/projects", 208 208 }) 209 209 } ··· 398 398 } 399 399 } 400 400 401 - ctx.JSON(http.StatusOK, map[string]interface{}{ 401 + ctx.JSON(http.StatusOK, map[string]any{ 402 402 "ok": true, 403 403 }) 404 404 } ··· 453 453 return 454 454 } 455 455 456 - ctx.JSON(http.StatusOK, map[string]interface{}{ 456 + ctx.JSON(http.StatusOK, map[string]any{ 457 457 "ok": true, 458 458 }) 459 459 } ··· 488 488 return 489 489 } 490 490 491 - ctx.JSON(http.StatusOK, map[string]interface{}{ 491 + ctx.JSON(http.StatusOK, map[string]any{ 492 492 "ok": true, 493 493 }) 494 494 } ··· 562 562 return 563 563 } 564 564 565 - ctx.JSON(http.StatusOK, map[string]interface{}{ 565 + ctx.JSON(http.StatusOK, map[string]any{ 566 566 "ok": true, 567 567 }) 568 568 } ··· 579 579 return 580 580 } 581 581 582 - ctx.JSON(http.StatusOK, map[string]interface{}{ 582 + ctx.JSON(http.StatusOK, map[string]any{ 583 583 "ok": true, 584 584 }) 585 585 } ··· 596 596 return 597 597 } 598 598 599 - ctx.JSON(http.StatusOK, map[string]interface{}{ 599 + ctx.JSON(http.StatusOK, map[string]any{ 600 600 "ok": true, 601 601 }) 602 602 } ··· 700 700 return 701 701 } 702 702 703 - ctx.JSON(http.StatusOK, map[string]interface{}{ 703 + ctx.JSON(http.StatusOK, map[string]any{ 704 704 "ok": true, 705 705 }) 706 706 }
+14 -14
routers/web/repo/pull.go
··· 802 802 return 803 803 } 804 804 805 - ctx.PageData["prReview"] = map[string]interface{}{ 805 + ctx.PageData["prReview"] = map[string]any{ 806 806 "numberOfFiles": diff.NumFiles, 807 807 "numberOfViewedFiles": diff.NumViewedFiles, 808 808 } ··· 937 937 if err = pull_service.Update(ctx, issue.PullRequest, ctx.Doer, message, rebase); err != nil { 938 938 if models.IsErrMergeConflicts(err) { 939 939 conflictError := err.(models.ErrMergeConflicts) 940 - flashError, err := ctx.RenderToString(tplAlertDetails, map[string]interface{}{ 940 + flashError, err := ctx.RenderToString(tplAlertDetails, map[string]any{ 941 941 "Message": ctx.Tr("repo.pulls.merge_conflict"), 942 942 "Summary": ctx.Tr("repo.pulls.merge_conflict_summary"), 943 943 "Details": utils.SanitizeFlashErrorString(conflictError.StdErr) + "<br>" + utils.SanitizeFlashErrorString(conflictError.StdOut), ··· 951 951 return 952 952 } else if models.IsErrRebaseConflicts(err) { 953 953 conflictError := err.(models.ErrRebaseConflicts) 954 - flashError, err := ctx.RenderToString(tplAlertDetails, map[string]interface{}{ 954 + flashError, err := ctx.RenderToString(tplAlertDetails, map[string]any{ 955 955 "Message": ctx.Tr("repo.pulls.rebase_conflict", utils.SanitizeFlashErrorString(conflictError.CommitSHA)), 956 956 "Summary": ctx.Tr("repo.pulls.rebase_conflict_summary"), 957 957 "Details": utils.SanitizeFlashErrorString(conflictError.StdErr) + "<br>" + utils.SanitizeFlashErrorString(conflictError.StdOut), ··· 1086 1086 ctx.Redirect(issue.Link()) 1087 1087 } else if models.IsErrMergeConflicts(err) { 1088 1088 conflictError := err.(models.ErrMergeConflicts) 1089 - flashError, err := ctx.RenderToString(tplAlertDetails, map[string]interface{}{ 1089 + flashError, err := ctx.RenderToString(tplAlertDetails, map[string]any{ 1090 1090 "Message": ctx.Tr("repo.editor.merge_conflict"), 1091 1091 "Summary": ctx.Tr("repo.editor.merge_conflict_summary"), 1092 1092 "Details": utils.SanitizeFlashErrorString(conflictError.StdErr) + "<br>" + utils.SanitizeFlashErrorString(conflictError.StdOut), ··· 1099 1099 ctx.Redirect(issue.Link()) 1100 1100 } else if models.IsErrRebaseConflicts(err) { 1101 1101 conflictError := err.(models.ErrRebaseConflicts) 1102 - flashError, err := ctx.RenderToString(tplAlertDetails, map[string]interface{}{ 1102 + flashError, err := ctx.RenderToString(tplAlertDetails, map[string]any{ 1103 1103 "Message": ctx.Tr("repo.pulls.rebase_conflict", utils.SanitizeFlashErrorString(conflictError.CommitSHA)), 1104 1104 "Summary": ctx.Tr("repo.pulls.rebase_conflict_summary"), 1105 1105 "Details": utils.SanitizeFlashErrorString(conflictError.StdErr) + "<br>" + utils.SanitizeFlashErrorString(conflictError.StdOut), ··· 1129 1129 if len(message) == 0 { 1130 1130 ctx.Flash.Error(ctx.Tr("repo.pulls.push_rejected_no_message")) 1131 1131 } else { 1132 - flashError, err := ctx.RenderToString(tplAlertDetails, map[string]interface{}{ 1132 + flashError, err := ctx.RenderToString(tplAlertDetails, map[string]any{ 1133 1133 "Message": ctx.Tr("repo.pulls.push_rejected"), 1134 1134 "Summary": ctx.Tr("repo.pulls.push_rejected_summary"), 1135 1135 "Details": utils.SanitizeFlashErrorString(pushrejErr.Message), ··· 1302 1302 ctx.JSONError(ctx.Tr("repo.pulls.push_rejected_no_message")) 1303 1303 return 1304 1304 } 1305 - flashError, err := ctx.RenderToString(tplAlertDetails, map[string]interface{}{ 1305 + flashError, err := ctx.RenderToString(tplAlertDetails, map[string]any{ 1306 1306 "Message": ctx.Tr("repo.pulls.push_rejected"), 1307 1307 "Summary": ctx.Tr("repo.pulls.push_rejected_summary"), 1308 1308 "Details": utils.SanitizeFlashErrorString(pushrejErr.Message), ··· 1407 1407 } 1408 1408 1409 1409 defer func() { 1410 - ctx.JSON(http.StatusOK, map[string]interface{}{ 1410 + ctx.JSON(http.StatusOK, map[string]any{ 1411 1411 "redirect": issue.Link(), 1412 1412 }) 1413 1413 }() ··· 1519 1519 errorMessage := ctx.Tr("repo.pulls.has_pull_request", html.EscapeString(ctx.Repo.RepoLink+"/pulls/"+strconv.FormatInt(err.IssueID, 10)), html.EscapeString(RepoRelPath), err.IssueID) // FIXME: Creates url inside locale string 1520 1520 1521 1521 ctx.Flash.Error(errorMessage) 1522 - ctx.JSON(http.StatusConflict, map[string]interface{}{ 1522 + ctx.JSON(http.StatusConflict, map[string]any{ 1523 1523 "error": err.Error(), 1524 1524 "user_error": errorMessage, 1525 1525 }) ··· 1527 1527 errorMessage := ctx.Tr("repo.pulls.is_closed") 1528 1528 1529 1529 ctx.Flash.Error(errorMessage) 1530 - ctx.JSON(http.StatusConflict, map[string]interface{}{ 1530 + ctx.JSON(http.StatusConflict, map[string]any{ 1531 1531 "error": err.Error(), 1532 1532 "user_error": errorMessage, 1533 1533 }) ··· 1535 1535 errorMessage := ctx.Tr("repo.pulls.has_merged") 1536 1536 1537 1537 ctx.Flash.Error(errorMessage) 1538 - ctx.JSON(http.StatusConflict, map[string]interface{}{ 1538 + ctx.JSON(http.StatusConflict, map[string]any{ 1539 1539 "error": err.Error(), 1540 1540 "user_error": errorMessage, 1541 1541 }) ··· 1543 1543 errorMessage := ctx.Tr("repo.pulls.nothing_to_compare") 1544 1544 1545 1545 ctx.Flash.Error(errorMessage) 1546 - ctx.JSON(http.StatusBadRequest, map[string]interface{}{ 1546 + ctx.JSON(http.StatusBadRequest, map[string]any{ 1547 1547 "error": err.Error(), 1548 1548 "user_error": errorMessage, 1549 1549 }) ··· 1554 1554 } 1555 1555 notification.NotifyPullRequestChangeTargetBranch(ctx, ctx.Doer, pr, targetBranch) 1556 1556 1557 - ctx.JSON(http.StatusOK, map[string]interface{}{ 1557 + ctx.JSON(http.StatusOK, map[string]any{ 1558 1558 "base_branch": pr.BaseBranch, 1559 1559 }) 1560 1560 } ··· 1582 1582 return 1583 1583 } 1584 1584 1585 - ctx.JSON(http.StatusOK, map[string]interface{}{ 1585 + ctx.JSON(http.StatusOK, map[string]any{ 1586 1586 "allow_maintainer_edit": pr.AllowMaintainerEdit, 1587 1587 }) 1588 1588 }
+1 -1
routers/web/repo/pull_review.go
··· 153 153 renderConversation(ctx, comment) 154 154 return 155 155 } 156 - ctx.JSON(http.StatusOK, map[string]interface{}{ 156 + ctx.JSON(http.StatusOK, map[string]any{ 157 157 "ok": true, 158 158 }) 159 159 }
+2 -2
routers/web/repo/release.go
··· 607 607 } 608 608 609 609 if isDelTag { 610 - ctx.JSON(http.StatusOK, map[string]interface{}{ 610 + ctx.JSON(http.StatusOK, map[string]any{ 611 611 "redirect": ctx.Repo.RepoLink + "/tags", 612 612 }) 613 613 return 614 614 } 615 615 616 - ctx.JSON(http.StatusOK, map[string]interface{}{ 616 + ctx.JSON(http.StatusOK, map[string]any{ 617 617 "redirect": ctx.Repo.RepoLink + "/releases", 618 618 }) 619 619 }
+2 -2
routers/web/repo/repo.go
··· 181 181 ctx.HTML(http.StatusOK, tplCreate) 182 182 } 183 183 184 - func handleCreateError(ctx *context.Context, owner *user_model.User, err error, name string, tpl base.TplName, form interface{}) { 184 + func handleCreateError(ctx *context.Context, owner *user_model.User, err error, name string, tpl base.TplName, form any) { 185 185 switch { 186 186 case repo_model.IsErrReachLimitOfRepo(err): 187 187 maxCreationLimit := owner.MaxCreationLimit() ··· 482 482 completed = true 483 483 } 484 484 485 - ctx.JSON(http.StatusOK, map[string]interface{}{ 485 + ctx.JSON(http.StatusOK, map[string]any{ 486 486 "complete": completed, 487 487 }) 488 488 }
+2 -2
routers/web/repo/setting/collaboration.go
··· 133 133 ctx.Flash.Success(ctx.Tr("repo.settings.remove_collaborator_success")) 134 134 } 135 135 136 - ctx.JSON(http.StatusOK, map[string]interface{}{ 136 + ctx.JSON(http.StatusOK, map[string]any{ 137 137 "redirect": ctx.Repo.RepoLink + "/settings/collaboration", 138 138 }) 139 139 } ··· 204 204 } 205 205 206 206 ctx.Flash.Success(ctx.Tr("repo.settings.remove_team_success")) 207 - ctx.JSON(http.StatusOK, map[string]interface{}{ 207 + ctx.JSON(http.StatusOK, map[string]any{ 208 208 "redirect": ctx.Repo.RepoLink + "/settings/collaboration", 209 209 }) 210 210 }
+1 -1
routers/web/repo/setting/deploy_key.go
··· 105 105 ctx.Flash.Success(ctx.Tr("repo.settings.deploy_key_deletion_success")) 106 106 } 107 107 108 - ctx.JSON(http.StatusOK, map[string]interface{}{ 108 + ctx.JSON(http.StatusOK, map[string]any{ 109 109 "redirect": ctx.Repo.RepoLink + "/settings/keys", 110 110 }) 111 111 }
+5 -5
routers/web/repo/setting/protected_branch.go
··· 307 307 ruleID := ctx.ParamsInt64("id") 308 308 if ruleID <= 0 { 309 309 ctx.Flash.Error(ctx.Tr("repo.settings.remove_protected_branch_failed", fmt.Sprintf("%d", ruleID))) 310 - ctx.JSON(http.StatusOK, map[string]interface{}{ 310 + ctx.JSON(http.StatusOK, map[string]any{ 311 311 "redirect": fmt.Sprintf("%s/settings/branches", ctx.Repo.RepoLink), 312 312 }) 313 313 return ··· 316 316 rule, err := git_model.GetProtectedBranchRuleByID(ctx, ctx.Repo.Repository.ID, ruleID) 317 317 if err != nil { 318 318 ctx.Flash.Error(ctx.Tr("repo.settings.remove_protected_branch_failed", fmt.Sprintf("%d", ruleID))) 319 - ctx.JSON(http.StatusOK, map[string]interface{}{ 319 + ctx.JSON(http.StatusOK, map[string]any{ 320 320 "redirect": fmt.Sprintf("%s/settings/branches", ctx.Repo.RepoLink), 321 321 }) 322 322 return ··· 324 324 325 325 if rule == nil { 326 326 ctx.Flash.Error(ctx.Tr("repo.settings.remove_protected_branch_failed", fmt.Sprintf("%d", ruleID))) 327 - ctx.JSON(http.StatusOK, map[string]interface{}{ 327 + ctx.JSON(http.StatusOK, map[string]any{ 328 328 "redirect": fmt.Sprintf("%s/settings/branches", ctx.Repo.RepoLink), 329 329 }) 330 330 return ··· 332 332 333 333 if err := git_model.DeleteProtectedBranch(ctx, ctx.Repo.Repository.ID, ruleID); err != nil { 334 334 ctx.Flash.Error(ctx.Tr("repo.settings.remove_protected_branch_failed", rule.RuleName)) 335 - ctx.JSON(http.StatusOK, map[string]interface{}{ 335 + ctx.JSON(http.StatusOK, map[string]any{ 336 336 "redirect": fmt.Sprintf("%s/settings/branches", ctx.Repo.RepoLink), 337 337 }) 338 338 return 339 339 } 340 340 341 341 ctx.Flash.Success(ctx.Tr("repo.settings.remove_protected_branch_success", rule.RuleName)) 342 - ctx.JSON(http.StatusOK, map[string]interface{}{ 342 + ctx.JSON(http.StatusOK, map[string]any{ 343 343 "redirect": fmt.Sprintf("%s/settings/branches", ctx.Repo.RepoLink), 344 344 }) 345 345 }
+3 -3
routers/web/repo/setting/webhook.go
··· 145 145 return 146 146 } 147 147 if hookType == "discord" { 148 - ctx.Data["DiscordHook"] = map[string]interface{}{ 148 + ctx.Data["DiscordHook"] = map[string]any{ 149 149 "Username": "Gitea", 150 150 } 151 151 } ··· 196 196 Secret string 197 197 HTTPMethod string 198 198 WebhookForm forms.WebhookForm 199 - Meta interface{} 199 + Meta any 200 200 } 201 201 202 202 func createWebhook(ctx *context.Context, params webhookParams) { ··· 729 729 ctx.Flash.Success(ctx.Tr("repo.settings.webhook_deletion_success")) 730 730 } 731 731 732 - ctx.JSON(http.StatusOK, map[string]interface{}{ 732 + ctx.JSON(http.StatusOK, map[string]any{ 733 733 "redirect": ctx.Repo.RepoLink + "/settings/hooks", 734 734 }) 735 735 }
+5 -5
routers/web/repo/topic.go
··· 15 15 // TopicsPost response for creating repository 16 16 func TopicsPost(ctx *context.Context) { 17 17 if ctx.Doer == nil { 18 - ctx.JSON(http.StatusForbidden, map[string]interface{}{ 18 + ctx.JSON(http.StatusForbidden, map[string]any{ 19 19 "message": "Only owners could change the topics.", 20 20 }) 21 21 return ··· 30 30 validTopics, invalidTopics := repo_model.SanitizeAndValidateTopics(topics) 31 31 32 32 if len(validTopics) > 25 { 33 - ctx.JSON(http.StatusUnprocessableEntity, map[string]interface{}{ 33 + ctx.JSON(http.StatusUnprocessableEntity, map[string]any{ 34 34 "invalidTopics": nil, 35 35 "message": ctx.Tr("repo.topic.count_prompt"), 36 36 }) ··· 38 38 } 39 39 40 40 if len(invalidTopics) > 0 { 41 - ctx.JSON(http.StatusUnprocessableEntity, map[string]interface{}{ 41 + ctx.JSON(http.StatusUnprocessableEntity, map[string]any{ 42 42 "invalidTopics": invalidTopics, 43 43 "message": ctx.Tr("repo.topic.format_prompt"), 44 44 }) ··· 48 48 err := repo_model.SaveTopics(ctx.Repo.Repository.ID, validTopics...) 49 49 if err != nil { 50 50 log.Error("SaveTopics failed: %v", err) 51 - ctx.JSON(http.StatusInternalServerError, map[string]interface{}{ 51 + ctx.JSON(http.StatusInternalServerError, map[string]any{ 52 52 "message": "Save topics failed.", 53 53 }) 54 54 return 55 55 } 56 56 57 - ctx.JSON(http.StatusOK, map[string]interface{}{ 57 + ctx.JSON(http.StatusOK, map[string]any{ 58 58 "status": "ok", 59 59 }) 60 60 }
+1 -1
routers/web/repo/wiki.go
··· 791 791 792 792 notification.NotifyDeleteWikiPage(ctx, ctx.Doer, ctx.Repo.Repository, string(wikiName)) 793 793 794 - ctx.JSON(http.StatusOK, map[string]interface{}{ 794 + ctx.JSON(http.StatusOK, map[string]any{ 795 795 "redirect": ctx.Repo.RepoLink + "/wiki/", 796 796 }) 797 797 }
+1 -1
routers/web/repo/wiki_test.go
··· 62 62 assert.Nil(t, wikiEntry(t, repo, wikiName)) 63 63 } 64 64 65 - func assertPagesMetas(t *testing.T, expectedNames []string, metas interface{}) { 65 + func assertPagesMetas(t *testing.T, expectedNames []string, metas any) { 66 66 pageMetas, ok := metas.([]PageMeta) 67 67 if !assert.True(t, ok) { 68 68 return
+2 -2
routers/web/shared/actions/runners.go
··· 160 160 log.Warn("DeleteRunnerPost.UpdateRunner failed: %v, url: %s", err, ctx.Req.URL) 161 161 ctx.Flash.Warning(ctx.Tr("actions.runners.delete_runner_failed")) 162 162 163 - ctx.JSON(http.StatusOK, map[string]interface{}{ 163 + ctx.JSON(http.StatusOK, map[string]any{ 164 164 "redirect": failedRedirectTo, 165 165 }) 166 166 return ··· 170 170 171 171 ctx.Flash.Success(ctx.Tr("actions.runners.delete_runner_success")) 172 172 173 - ctx.JSON(http.StatusOK, map[string]interface{}{ 173 + ctx.JSON(http.StatusOK, map[string]any{ 174 174 "redirect": successRedirectTo, 175 175 }) 176 176 }
+1 -1
routers/web/user/home.go
··· 97 97 uid = ctxUser.ID 98 98 } 99 99 100 - ctx.PageData["dashboardRepoList"] = map[string]interface{}{ 100 + ctx.PageData["dashboardRepoList"] = map[string]any{ 101 101 "searchLimit": setting.UI.User.RepoPagingNum, 102 102 "uid": uid, 103 103 }
+2 -2
routers/web/user/search.go
··· 28 28 ListOptions: listOptions, 29 29 }) 30 30 if err != nil { 31 - ctx.JSON(http.StatusInternalServerError, map[string]interface{}{ 31 + ctx.JSON(http.StatusInternalServerError, map[string]any{ 32 32 "ok": false, 33 33 "error": err.Error(), 34 34 }) ··· 37 37 38 38 ctx.SetTotalCountHeader(maxResults) 39 39 40 - ctx.JSON(http.StatusOK, map[string]interface{}{ 40 + ctx.JSON(http.StatusOK, map[string]any{ 41 41 "ok": true, 42 42 "data": convert.ToUsers(ctx, ctx.Doer, users), 43 43 })
+1 -1
routers/web/user/setting/account.go
··· 227 227 log.Trace("Email address deleted: %s", ctx.Doer.Name) 228 228 229 229 ctx.Flash.Success(ctx.Tr("settings.email_deletion_success")) 230 - ctx.JSON(http.StatusOK, map[string]interface{}{ 230 + ctx.JSON(http.StatusOK, map[string]any{ 231 231 "redirect": setting.AppSubURL + "/user/settings/account", 232 232 }) 233 233 }
+1 -1
routers/web/user/setting/applications.go
··· 83 83 ctx.Flash.Success(ctx.Tr("settings.delete_token_success")) 84 84 } 85 85 86 - ctx.JSON(http.StatusOK, map[string]interface{}{ 86 + ctx.JSON(http.StatusOK, map[string]any{ 87 87 "redirect": setting.AppSubURL + "/user/settings/applications", 88 88 }) 89 89 }
+1 -1
routers/web/user/setting/keys.go
··· 256 256 ctx.Flash.Warning("Function not implemented") 257 257 ctx.Redirect(setting.AppSubURL + "/user/settings/keys") 258 258 } 259 - ctx.JSON(http.StatusOK, map[string]interface{}{ 259 + ctx.JSON(http.StatusOK, map[string]any{ 260 260 "redirect": setting.AppSubURL + "/user/settings/keys", 261 261 }) 262 262 }
+2 -2
routers/web/user/setting/oauth2_common.go
··· 138 138 } 139 139 140 140 ctx.Flash.Success(ctx.Tr("settings.remove_oauth2_application_success")) 141 - ctx.JSON(http.StatusOK, map[string]interface{}{"redirect": oa.BasePathList}) 141 + ctx.JSON(http.StatusOK, map[string]any{"redirect": oa.BasePathList}) 142 142 } 143 143 144 144 // RevokeGrant revokes the grant ··· 149 149 } 150 150 151 151 ctx.Flash.Success(ctx.Tr("settings.revoke_oauth2_grant_success")) 152 - ctx.JSON(http.StatusOK, map[string]interface{}{"redirect": oa.BasePathList}) 152 + ctx.JSON(http.StatusOK, map[string]any{"redirect": oa.BasePathList}) 153 153 }
+1 -1
routers/web/user/setting/security/openid.go
··· 112 112 log.Trace("OpenID address deleted: %s", ctx.Doer.Name) 113 113 114 114 ctx.Flash.Success(ctx.Tr("settings.openid_deletion_success")) 115 - ctx.JSON(http.StatusOK, map[string]interface{}{ 115 + ctx.JSON(http.StatusOK, map[string]any{ 116 116 "redirect": setting.AppSubURL + "/user/settings/security", 117 117 }) 118 118 }
+1 -1
routers/web/user/setting/security/security.go
··· 48 48 } 49 49 } 50 50 51 - ctx.JSON(http.StatusOK, map[string]interface{}{ 51 + ctx.JSON(http.StatusOK, map[string]any{ 52 52 "redirect": setting.AppSubURL + "/user/settings/security", 53 53 }) 54 54 }
+1 -1
routers/web/user/setting/security/webauthn.go
··· 116 116 ctx.ServerError("GetWebAuthnCredentialByID", err) 117 117 return 118 118 } 119 - ctx.JSON(http.StatusOK, map[string]interface{}{ 119 + ctx.JSON(http.StatusOK, map[string]any{ 120 120 "redirect": setting.AppSubURL + "/user/settings/security", 121 121 }) 122 122 }
+1 -1
routers/web/user/setting/webhooks.go
··· 42 42 ctx.Flash.Success(ctx.Tr("repo.settings.webhook_deletion_success")) 43 43 } 44 44 45 - ctx.JSON(http.StatusOK, map[string]interface{}{ 45 + ctx.JSON(http.StatusOK, map[string]any{ 46 46 "redirect": setting.AppSubURL + "/user/settings/hooks", 47 47 }) 48 48 }
+4 -4
routers/web/user/task.go
··· 17 17 task, opts, err := admin_model.GetMigratingTaskByID(ctx.ParamsInt64("task"), ctx.Doer.ID) 18 18 if err != nil { 19 19 if admin_model.IsErrTaskDoesNotExist(err) { 20 - ctx.JSON(http.StatusNotFound, map[string]interface{}{ 20 + ctx.JSON(http.StatusNotFound, map[string]any{ 21 21 "error": "task `" + strconv.FormatInt(ctx.ParamsInt64("task"), 10) + "` does not exist", 22 22 }) 23 23 return 24 24 } 25 - ctx.JSON(http.StatusInternalServerError, map[string]interface{}{ 25 + ctx.JSON(http.StatusInternalServerError, map[string]any{ 26 26 "err": err, 27 27 }) 28 28 return ··· 36 36 if err := json.Unmarshal([]byte(message), &translatableMessage); err != nil { 37 37 translatableMessage = admin_model.TranslatableMessage{ 38 38 Format: "migrate.migrating_failed.error", 39 - Args: []interface{}{task.Message}, 39 + Args: []any{task.Message}, 40 40 } 41 41 } 42 42 message = ctx.Tr(translatableMessage.Format, translatableMessage.Args...) 43 43 } 44 44 45 - ctx.JSON(http.StatusOK, map[string]interface{}{ 45 + ctx.JSON(http.StatusOK, map[string]any{ 46 46 "status": task.Status, 47 47 "message": message, 48 48 "repo-id": task.RepoID,
+9 -9
routers/web/webfinger.go
··· 18 18 // https://datatracker.ietf.org/doc/html/draft-ietf-appsawg-webfinger-14#section-4.4 19 19 20 20 type webfingerJRD struct { 21 - Subject string `json:"subject,omitempty"` 22 - Aliases []string `json:"aliases,omitempty"` 23 - Properties map[string]interface{} `json:"properties,omitempty"` 24 - Links []*webfingerLink `json:"links,omitempty"` 21 + Subject string `json:"subject,omitempty"` 22 + Aliases []string `json:"aliases,omitempty"` 23 + Properties map[string]any `json:"properties,omitempty"` 24 + Links []*webfingerLink `json:"links,omitempty"` 25 25 } 26 26 27 27 type webfingerLink struct { 28 - Rel string `json:"rel,omitempty"` 29 - Type string `json:"type,omitempty"` 30 - Href string `json:"href,omitempty"` 31 - Titles map[string]string `json:"titles,omitempty"` 32 - Properties map[string]interface{} `json:"properties,omitempty"` 28 + Rel string `json:"rel,omitempty"` 29 + Type string `json:"type,omitempty"` 30 + Href string `json:"href,omitempty"` 31 + Titles map[string]string `json:"titles,omitempty"` 32 + Properties map[string]any `json:"properties,omitempty"` 33 33 } 34 34 35 35 // WebfingerQuery returns information about a resource
+15 -15
services/auth/source/oauth2/jwtsigningkey.go
··· 38 38 type JWTSigningKey interface { 39 39 IsSymmetric() bool 40 40 SigningMethod() jwt.SigningMethod 41 - SignKey() interface{} 42 - VerifyKey() interface{} 41 + SignKey() any 42 + VerifyKey() any 43 43 ToJWK() (map[string]string, error) 44 44 PreProcessToken(*jwt.Token) 45 45 } ··· 57 57 return key.signingMethod 58 58 } 59 59 60 - func (key hmacSigningKey) SignKey() interface{} { 60 + func (key hmacSigningKey) SignKey() any { 61 61 return key.secret 62 62 } 63 63 64 - func (key hmacSigningKey) VerifyKey() interface{} { 64 + func (key hmacSigningKey) VerifyKey() any { 65 65 return key.secret 66 66 } 67 67 ··· 101 101 return key.signingMethod 102 102 } 103 103 104 - func (key rsaSingingKey) SignKey() interface{} { 104 + func (key rsaSingingKey) SignKey() any { 105 105 return key.key 106 106 } 107 107 108 - func (key rsaSingingKey) VerifyKey() interface{} { 108 + func (key rsaSingingKey) VerifyKey() any { 109 109 return key.key.Public() 110 110 } 111 111 ··· 152 152 return key.signingMethod 153 153 } 154 154 155 - func (key eddsaSigningKey) SignKey() interface{} { 155 + func (key eddsaSigningKey) SignKey() any { 156 156 return key.key 157 157 } 158 158 159 - func (key eddsaSigningKey) VerifyKey() interface{} { 159 + func (key eddsaSigningKey) VerifyKey() any { 160 160 return key.key.Public() 161 161 } 162 162 ··· 203 203 return key.signingMethod 204 204 } 205 205 206 - func (key ecdsaSingingKey) SignKey() interface{} { 206 + func (key ecdsaSingingKey) SignKey() any { 207 207 return key.key 208 208 } 209 209 210 - func (key ecdsaSingingKey) VerifyKey() interface{} { 210 + func (key ecdsaSingingKey) VerifyKey() any { 211 211 return key.key.Public() 212 212 } 213 213 ··· 229 229 } 230 230 231 231 // CreateJWTSigningKey creates a signing key from an algorithm / key pair. 232 - func CreateJWTSigningKey(algorithm string, key interface{}) (JWTSigningKey, error) { 232 + func CreateJWTSigningKey(algorithm string, key any) (JWTSigningKey, error) { 233 233 var signingMethod jwt.SigningMethod 234 234 switch algorithm { 235 235 case "HS256": ··· 292 292 // InitSigningKey creates the default signing key from settings or creates a random key. 293 293 func InitSigningKey() error { 294 294 var err error 295 - var key interface{} 295 + var key any 296 296 297 297 switch setting.OAuth2.JWTSigningAlgorithm { 298 298 case "HS256": ··· 335 335 336 336 // loadSymmetricKey checks if the configured secret is valid. 337 337 // If it is not valid, it will return an error. 338 - func loadSymmetricKey() (interface{}, error) { 338 + func loadSymmetricKey() (any, error) { 339 339 key := make([]byte, 32) 340 340 n, err := base64.RawURLEncoding.Decode(key, []byte(setting.OAuth2.JWTSecretBase64)) 341 341 if err != nil { ··· 350 350 351 351 // loadOrCreateAsymmetricKey checks if the configured private key exists. 352 352 // If it does not exist a new random key gets generated and saved on the configured path. 353 - func loadOrCreateAsymmetricKey() (interface{}, error) { 353 + func loadOrCreateAsymmetricKey() (any, error) { 354 354 keyPath := setting.OAuth2.JWTSigningPrivateKeyFile 355 355 356 356 isExist, err := util.IsExist(keyPath) ··· 359 359 } 360 360 if !isExist { 361 361 err := func() error { 362 - key, err := func() (interface{}, error) { 362 + key, err := func() (any, error) { 363 363 switch { 364 364 case strings.HasPrefix(setting.OAuth2.JWTSigningAlgorithm, "RS"): 365 365 return rsa.GenerateKey(rand.Reader, 4096)
+1 -1
services/auth/source/oauth2/token.go
··· 41 41 42 42 // ParseToken parses a signed jwt string 43 43 func ParseToken(jwtToken string, signingKey JWTSigningKey) (*Token, error) { 44 - parsedToken, err := jwt.ParseWithClaims(jwtToken, &Token{}, func(token *jwt.Token) (interface{}, error) { 44 + parsedToken, err := jwt.ParseWithClaims(jwtToken, &Token{}, func(token *jwt.Token) (any, error) { 45 45 if token.Method == nil || token.Method.Alg() != signingKey.SigningMethod().Alg() { 46 46 return nil, fmt.Errorf("unexpected signing algo: %v", token.Header["alg"]) 47 47 }
+2 -2
services/context/user.go
··· 15 15 // UserAssignmentWeb returns a middleware to handle context-user assignment for web routes 16 16 func UserAssignmentWeb() func(ctx *context.Context) { 17 17 return func(ctx *context.Context) { 18 - errorFn := func(status int, title string, obj interface{}) { 18 + errorFn := func(status int, title string, obj any) { 19 19 err, ok := obj.(error) 20 20 if !ok { 21 21 err = fmt.Errorf("%s", obj) ··· 58 58 } 59 59 } 60 60 61 - func userAssignment(ctx *context.Base, doer *user_model.User, errCb func(int, string, interface{})) (contextUser *user_model.User) { 61 + func userAssignment(ctx *context.Base, doer *user_model.User, errCb func(int, string, any)) (contextUser *user_model.User) { 62 62 username := ctx.Params(":username") 63 63 64 64 if doer != nil && doer.LowerName == strings.ToLower(username) {
+3 -3
services/cron/setting.go
··· 14 14 IsEnabled() bool 15 15 DoRunAtStart() bool 16 16 GetSchedule() string 17 - FormatMessage(locale translation.Locale, name, status, doer string, args ...interface{}) string 17 + FormatMessage(locale translation.Locale, name, status, doer string, args ...any) string 18 18 DoNoticeOnSuccess() bool 19 19 } 20 20 ··· 68 68 69 69 // FormatMessage returns a message for the task 70 70 // Please note the `status` string will be concatenated with `admin.dashboard.cron.` and `admin.dashboard.task.` to provide locale messages. Similarly `name` will be composed with `admin.dashboard.` to provide the locale name for the task. 71 - func (b *BaseConfig) FormatMessage(locale translation.Locale, name, status, doer string, args ...interface{}) string { 72 - realArgs := make([]interface{}, 0, len(args)+2) 71 + func (b *BaseConfig) FormatMessage(locale translation.Locale, name, status, doer string, args ...any) string { 72 + realArgs := make([]any, 0, len(args)+2) 73 73 realArgs = append(realArgs, locale.Tr("admin.dashboard."+name)) 74 74 if doer == "" { 75 75 realArgs = append(realArgs, "(Cron)")
+2 -2
services/externalaccount/link.go
··· 13 13 14 14 // Store represents a thing that stores things 15 15 type Store interface { 16 - Get(interface{}) interface{} 17 - Set(interface{}, interface{}) error 16 + Get(any) any 17 + Set(any, any) error 18 18 Release() error 19 19 } 20 20
+2 -2
services/lfs/server.go
··· 375 375 writeStatus(ctx, status) 376 376 } 377 377 378 - func decodeJSON(req *http.Request, v interface{}) error { 378 + func decodeJSON(req *http.Request, v any) error { 379 379 defer req.Body.Close() 380 380 381 381 dec := json.NewDecoder(req.Body) ··· 552 552 if !strings.Contains(tokenSHA, ".") { 553 553 return nil, nil 554 554 } 555 - token, err := jwt.ParseWithClaims(tokenSHA, &Claims{}, func(t *jwt.Token) (interface{}, error) { 555 + token, err := jwt.ParseWithClaims(tokenSHA, &Claims{}, func(t *jwt.Token) (any, error) { 556 556 if _, ok := t.Method.(*jwt.SigningMethodHMAC); !ok { 557 557 return nil, fmt.Errorf("unexpected signing method: %v", t.Header["alg"]) 558 558 }
+1 -1
services/mailer/incoming/incoming.go
··· 205 205 if err := c.Store( 206 206 handledSet, 207 207 imap.FormatFlagsOp(imap.AddFlags, true), 208 - []interface{}{imap.DeletedFlag}, 208 + []any{imap.DeletedFlag}, 209 209 nil, 210 210 ); err != nil { 211 211 return fmt.Errorf("imap store failed: %w", err)
+2 -2
services/mailer/incoming/payload/payload.go
··· 20 20 ) 21 21 22 22 // CreateReferencePayload creates data which GetReferenceFromPayload resolves to the reference again. 23 - func CreateReferencePayload(reference interface{}) ([]byte, error) { 23 + func CreateReferencePayload(reference any) ([]byte, error) { 24 24 var refType payloadReferenceType 25 25 var refID int64 26 26 ··· 44 44 } 45 45 46 46 // GetReferenceFromPayload resolves the reference from the payload 47 - func GetReferenceFromPayload(ctx context.Context, payload []byte) (interface{}, error) { 47 + func GetReferenceFromPayload(ctx context.Context, payload []byte) (any, error) { 48 48 if len(payload) < 1 { 49 49 return nil, util.NewInvalidArgumentErrorf("payload to small") 50 50 }
+5 -5
services/mailer/mail.go
··· 67 67 // sendUserMail sends a mail to the user 68 68 func sendUserMail(language string, u *user_model.User, tpl base.TplName, code, subject, info string) { 69 69 locale := translation.NewLocale(language) 70 - data := map[string]interface{}{ 70 + data := map[string]any{ 71 71 "DisplayName": u.DisplayName(), 72 72 "ActiveCodeLives": timeutil.MinutesToFriendly(setting.Service.ActiveCodeLives, locale), 73 73 "ResetPwdCodeLives": timeutil.MinutesToFriendly(setting.Service.ResetPwdCodeLives, locale), ··· 118 118 return 119 119 } 120 120 locale := translation.NewLocale(u.Language) 121 - data := map[string]interface{}{ 121 + data := map[string]any{ 122 122 "DisplayName": u.DisplayName(), 123 123 "ActiveCodeLives": timeutil.MinutesToFriendly(setting.Service.ActiveCodeLives, locale), 124 124 "Code": u.GenerateEmailActivateCode(email.Email), ··· 151 151 } 152 152 locale := translation.NewLocale(u.Language) 153 153 154 - data := map[string]interface{}{ 154 + data := map[string]any{ 155 155 "DisplayName": u.DisplayName(), 156 156 "Username": u.Name, 157 157 "Language": locale.Language(), ··· 184 184 repoName := repo.FullName() 185 185 186 186 subject := locale.Tr("mail.repo.collaborator.added.subject", doer.DisplayName(), repoName) 187 - data := map[string]interface{}{ 187 + data := map[string]any{ 188 188 "Subject": subject, 189 189 "RepoName": repoName, 190 190 "Link": repo.HTMLURL(), ··· 258 258 } 259 259 locale := translation.NewLocale(lang) 260 260 261 - mailMeta := map[string]interface{}{ 261 + mailMeta := map[string]any{ 262 262 "FallbackSubject": fallback, 263 263 "Body": body, 264 264 "Link": link,
+1 -1
services/mailer/mail_release.go
··· 68 68 } 69 69 70 70 subject := locale.Tr("mail.release.new.subject", rel.TagName, rel.Repo.FullName()) 71 - mailMeta := map[string]interface{}{ 71 + mailMeta := map[string]any{ 72 72 "Release": rel, 73 73 "Subject": subject, 74 74 "Language": locale.Language(),
+1 -1
services/mailer/mail_repo.go
··· 64 64 subject = locale.Tr("mail.repo.transfer.subject_to", doer.DisplayName(), repo.FullName(), destination) 65 65 } 66 66 67 - data := map[string]interface{}{ 67 + data := map[string]any{ 68 68 "Doer": doer, 69 69 "User": repo.Owner, 70 70 "Repo": repo.FullName(),
+1 -1
services/mailer/mail_team_invite.go
··· 34 34 locale := translation.NewLocale(inviter.Language) 35 35 36 36 subject := locale.Tr("mail.team_invite.subject", inviter.DisplayName(), org.DisplayName()) 37 - mailMeta := map[string]interface{}{ 37 + mailMeta := map[string]any{ 38 38 "Inviter": inviter, 39 39 "Organization": org, 40 40 "Team": team,
+1 -1
services/migrations/codebase.go
··· 127 127 return opts.CloneAddr, nil 128 128 } 129 129 130 - func (d *CodebaseDownloader) callAPI(endpoint string, parameter map[string]string, result interface{}) error { 130 + func (d *CodebaseDownloader) callAPI(endpoint string, parameter map[string]string, result any) error { 131 131 u, err := d.baseURL.Parse(endpoint) 132 132 if err != nil { 133 133 return err
+1 -1
services/migrations/common.go
··· 14 14 ) 15 15 16 16 // WarnAndNotice will log the provided message and send a repository notice 17 - func WarnAndNotice(fmtStr string, args ...interface{}) { 17 + func WarnAndNotice(fmtStr string, args ...any) { 18 18 log.Warn(fmtStr, args...) 19 19 if err := system_model.CreateRepositoryNotice(fmt.Sprintf(fmtStr, args...)); err != nil { 20 20 log.Error("create repository notice failed: ", err)
+6 -6
services/migrations/dump.go
··· 112 112 } 113 113 defer f.Close() 114 114 115 - bs, err := yaml.Marshal(map[string]interface{}{ 115 + bs, err := yaml.Marshal(map[string]any{ 116 116 "name": repo.Name, 117 117 "owner": repo.Owner, 118 118 "description": repo.Description, ··· 227 227 } 228 228 defer f.Close() 229 229 230 - bs, err := yaml.Marshal(map[string]interface{}{ 230 + bs, err := yaml.Marshal(map[string]any{ 231 231 "topics": topics, 232 232 }) 233 233 if err != nil { ··· 380 380 return nil 381 381 } 382 382 383 - func (g *RepositoryDumper) createItems(dir string, itemFiles map[int64]*os.File, itemsMap map[int64][]interface{}) error { 383 + func (g *RepositoryDumper) createItems(dir string, itemFiles map[int64]*os.File, itemsMap map[int64][]any) error { 384 384 if err := os.MkdirAll(dir, os.ModePerm); err != nil { 385 385 return err 386 386 } ··· 394 394 return nil 395 395 } 396 396 397 - func (g *RepositoryDumper) encodeItems(number int64, items []interface{}, dir string, itemFiles map[int64]*os.File) error { 397 + func (g *RepositoryDumper) encodeItems(number int64, items []any, dir string, itemFiles map[int64]*os.File) error { 398 398 itemFile := itemFiles[number] 399 399 if itemFile == nil { 400 400 var err error ··· 413 413 414 414 // CreateComments creates comments of issues 415 415 func (g *RepositoryDumper) CreateComments(comments ...*base.Comment) error { 416 - commentsMap := make(map[int64][]interface{}, len(comments)) 416 + commentsMap := make(map[int64][]any, len(comments)) 417 417 for _, comment := range comments { 418 418 commentsMap[comment.IssueIndex] = append(commentsMap[comment.IssueIndex], comment) 419 419 } ··· 621 621 622 622 // CreateReviews create pull request reviews 623 623 func (g *RepositoryDumper) CreateReviews(reviews ...*base.Review) error { 624 - reviewsMap := make(map[int64][]interface{}, len(reviews)) 624 + reviewsMap := make(map[int64][]any, len(reviews)) 625 625 for _, review := range reviews { 626 626 reviewsMap[review.IssueIndex] = append(reviewsMap[review.IssueIndex], review) 627 627 }
+4 -4
services/migrations/onedev.go
··· 121 121 return fmt.Sprintf("<OneDevDownloader %s [%d]/%s>", d.baseURL, d.repoID, d.repoName) 122 122 } 123 123 124 - func (d *OneDevDownloader) callAPI(endpoint string, parameter map[string]string, result interface{}) error { 124 + func (d *OneDevDownloader) callAPI(endpoint string, parameter map[string]string, result any) error { 125 125 u, err := d.baseURL.Parse(endpoint) 126 126 if err != nil { 127 127 return err ··· 400 400 } 401 401 402 402 rawChanges := make([]struct { 403 - Date time.Time `json:"date"` 404 - UserID int64 `json:"userId"` 405 - Data map[string]interface{} `json:"data"` 403 + Date time.Time `json:"date"` 404 + UserID int64 `json:"userId"` 405 + Data map[string]any `json:"data"` 406 406 }, 0, 100) 407 407 408 408 if context.IsPullRequest {
+3 -3
services/mirror/mirror.go
··· 41 41 } 42 42 log.Trace("Doing: Update") 43 43 44 - handler := func(idx int, bean interface{}) error { 44 + handler := func(idx int, bean any) error { 45 45 var repo *repo_model.Repository 46 46 var mirrorType mirror_module.SyncType 47 47 var referenceID int64 ··· 91 91 92 92 pullMirrorsRequested := 0 93 93 if pullLimit != 0 { 94 - if err := repo_model.MirrorsIterate(pullLimit, func(idx int, bean interface{}) error { 94 + if err := repo_model.MirrorsIterate(pullLimit, func(idx int, bean any) error { 95 95 if err := handler(idx, bean); err != nil { 96 96 return err 97 97 } ··· 105 105 106 106 pushMirrorsRequested := 0 107 107 if pushLimit != 0 { 108 - if err := repo_model.PushMirrorsIterate(ctx, pushLimit, func(idx int, bean interface{}) error { 108 + if err := repo_model.PushMirrorsIterate(ctx, pushLimit, func(idx int, bean any) error { 109 109 if err := handler(idx, bean); err != nil { 110 110 return err 111 111 }
+1 -1
services/packages/auth.go
··· 53 53 return 0, fmt.Errorf("split token failed") 54 54 } 55 55 56 - token, err := jwt.ParseWithClaims(parts[1], &packageClaims{}, func(t *jwt.Token) (interface{}, error) { 56 + token, err := jwt.ParseWithClaims(parts[1], &packageClaims{}, func(t *jwt.Token) (any, error) { 57 57 if _, ok := t.Method.(*jwt.SigningMethodHMAC); !ok { 58 58 return nil, fmt.Errorf("unexpected signing method: %v", t.Header["alg"]) 59 59 }
+1 -1
services/packages/packages.go
··· 44 44 PackageInfo 45 45 SemverCompatible bool 46 46 Creator *user_model.User 47 - Metadata interface{} 47 + Metadata any 48 48 PackageProperties map[string]string 49 49 VersionProperties map[string]string 50 50 }
+2 -2
services/repository/files/content.go
··· 40 40 41 41 // GetContentsOrList gets the meta data of a file's contents (*ContentsResponse) if treePath not a tree 42 42 // directory, otherwise a listing of file contents ([]*ContentsResponse). Ref can be a branch, commit or tag 43 - func GetContentsOrList(ctx context.Context, repo *repo_model.Repository, treePath, ref string) (interface{}, error) { 43 + func GetContentsOrList(ctx context.Context, repo *repo_model.Repository, treePath, ref string) (any, error) { 44 44 if repo.IsEmpty { 45 - return make([]interface{}, 0), nil 45 + return make([]any, 0), nil 46 46 } 47 47 if ref == "" { 48 48 ref = repo.DefaultBranch
+1 -1
services/task/migrate.go
··· 121 121 } 122 122 }() 123 123 124 - t.Repo, err = migrations.MigrateRepository(ctx, t.Doer, t.Owner.Name, *opts, func(format string, args ...interface{}) { 124 + t.Repo, err = migrations.MigrateRepository(ctx, t.Doer, t.Owner.Name, *opts, func(format string, args ...any) { 125 125 message := admin_model.TranslatableMessage{ 126 126 Format: format, 127 127 Args: args,
+1 -1
tests/integration/api_admin_test.go
··· 207 207 }) 208 208 resp := MakeRequest(t, req, http.StatusUnprocessableEntity) 209 209 210 - errMap := make(map[string]interface{}) 210 + errMap := make(map[string]any) 211 211 json.Unmarshal(resp.Body.Bytes(), &errMap) 212 212 assert.EqualValues(t, "email is not allowed to be empty string", errMap["message"].(string)) 213 213
+1 -1
tests/integration/api_packages_conan_test.go
··· 177 177 resp := MakeRequest(t, req, http.StatusOK) 178 178 179 179 var list *struct { 180 - Files map[string]interface{} `json:"files"` 180 + Files map[string]any `json:"files"` 181 181 } 182 182 DecodeJSON(t, resp, &list) 183 183 assert.Len(t, list.Files, 1)
+1 -1
tests/integration/api_packages_nuget_test.go
··· 35 35 return request 36 36 } 37 37 38 - func decodeXML(t testing.TB, resp *httptest.ResponseRecorder, v interface{}) { 38 + func decodeXML(t testing.TB, resp *httptest.ResponseRecorder, v any) { 39 39 t.Helper() 40 40 41 41 assert.NoError(t, xml.NewDecoder(resp.Body).Decode(v))
+8 -8
tests/integration/api_packages_pub_test.go
··· 131 131 resp := MakeRequest(t, req, http.StatusOK) 132 132 133 133 type VersionMetadata struct { 134 - Version string `json:"version"` 135 - ArchiveURL string `json:"archive_url"` 136 - Published time.Time `json:"published"` 137 - Pubspec interface{} `json:"pubspec,omitempty"` 134 + Version string `json:"version"` 135 + ArchiveURL string `json:"archive_url"` 136 + Published time.Time `json:"published"` 137 + Pubspec any `json:"pubspec,omitempty"` 138 138 } 139 139 140 140 var result VersionMetadata ··· 156 156 resp := MakeRequest(t, req, http.StatusOK) 157 157 158 158 type VersionMetadata struct { 159 - Version string `json:"version"` 160 - ArchiveURL string `json:"archive_url"` 161 - Published time.Time `json:"published"` 162 - Pubspec interface{} `json:"pubspec,omitempty"` 159 + Version string `json:"version"` 160 + ArchiveURL string `json:"archive_url"` 161 + Published time.Time `json:"published"` 162 + Pubspec any `json:"pubspec,omitempty"` 163 163 } 164 164 165 165 type PackageVersions struct {
+1 -1
tests/integration/api_packages_rpm_test.go
··· 219 219 assert.Contains(t, resp.Body.String(), "-----BEGIN PGP SIGNATURE-----") 220 220 }) 221 221 222 - decodeGzipXML := func(t testing.TB, resp *httptest.ResponseRecorder, v interface{}) { 222 + decodeGzipXML := func(t testing.TB, resp *httptest.ResponseRecorder, v any) { 223 223 t.Helper() 224 224 225 225 zr, err := gzip.NewReader(resp.Body)
+1 -1
tests/integration/api_pull_review_test.go
··· 195 195 Comments: []api.CreatePullReviewComment{}, 196 196 }) 197 197 resp = MakeRequest(t, req, http.StatusUnprocessableEntity) 198 - errMap := make(map[string]interface{}) 198 + errMap := make(map[string]any) 199 199 json.Unmarshal(resp.Body.Bytes(), &errMap) 200 200 assert.EqualValues(t, "review event COMMENT requires a body or a comment", errMap["message"].(string)) 201 201
+1 -1
tests/integration/api_token_test.go
··· 519 519 // createAPIAccessTokenWithoutCleanUp Create an API access token and assert that 520 520 // creation succeeded. The caller is responsible for deleting the token. 521 521 func createAPIAccessTokenWithoutCleanUp(t *testing.T, tokenName string, user *user_model.User, scopes *[]auth_model.AccessTokenScope) api.AccessToken { 522 - payload := map[string]interface{}{ 522 + payload := map[string]any{ 523 523 "name": tokenName, 524 524 } 525 525 if scopes != nil {
+6 -6
tests/integration/dump_restore_test.go
··· 121 121 } 122 122 123 123 type compareField struct { 124 - before interface{} 125 - after interface{} 124 + before any 125 + after any 126 126 ignore bool 127 127 transform func(string) string 128 128 nested *compareFields ··· 215 215 } 216 216 } 217 217 218 - func (c *compareDump) assertLoadYAMLFiles(beforeFilename, afterFilename string, before, after interface{}) { 218 + func (c *compareDump) assertLoadYAMLFiles(beforeFilename, afterFilename string, before, after any) { 219 219 _, beforeErr := os.Stat(beforeFilename) 220 220 _, afterErr := os.Stat(afterFilename) 221 221 assert.EqualValues(c.t, errors.Is(beforeErr, os.ErrNotExist), errors.Is(afterErr, os.ErrNotExist)) ··· 255 255 return beforePtr.Elem(), afterPtr.Elem() 256 256 } 257 257 258 - func (c *compareDump) assertEqual(filename string, kind interface{}, fields compareFields) (i interface{}) { 258 + func (c *compareDump) assertEqual(filename string, kind any, fields compareFields) (i any) { 259 259 beforeFilename := filepath.Join(c.dirBefore, filename) 260 260 afterFilename := filepath.Join(c.dirAfter, filename) 261 261 ··· 269 269 return i 270 270 } 271 271 272 - func (c *compareDump) assertEqualSlices(before, after reflect.Value, fields compareFields) interface{} { 272 + func (c *compareDump) assertEqualSlices(before, after reflect.Value, fields compareFields) any { 273 273 assert.EqualValues(c.t, before.Len(), after.Len()) 274 274 if before.Len() == after.Len() { 275 275 for i := 0; i < before.Len(); i++ { ··· 282 282 return after.Interface() 283 283 } 284 284 285 - func (c *compareDump) assertEqualValues(before, after reflect.Value, fields compareFields) interface{} { 285 + func (c *compareDump) assertEqualValues(before, after reflect.Value, fields compareFields) any { 286 286 for _, field := range reflect.VisibleFields(before.Type()) { 287 287 bf := before.FieldByName(field.Name) 288 288 bi := bf.Interface()
+3 -3
tests/integration/integration_test.go
··· 319 319 return NewRequestWithBody(t, method, urlStr, nil) 320 320 } 321 321 322 - func NewRequestf(t testing.TB, method, urlFormat string, args ...interface{}) *http.Request { 322 + func NewRequestf(t testing.TB, method, urlFormat string, args ...any) *http.Request { 323 323 t.Helper() 324 324 return NewRequest(t, method, fmt.Sprintf(urlFormat, args...)) 325 325 } ··· 340 340 return req 341 341 } 342 342 343 - func NewRequestWithJSON(t testing.TB, method, urlStr string, v interface{}) *http.Request { 343 + func NewRequestWithJSON(t testing.TB, method, urlStr string, v any) *http.Request { 344 344 t.Helper() 345 345 346 346 jsonBytes, err := json.Marshal(v) ··· 435 435 } 436 436 } 437 437 438 - func DecodeJSON(t testing.TB, resp *httptest.ResponseRecorder, v interface{}) { 438 + func DecodeJSON(t testing.TB, resp *httptest.ResponseRecorder, v any) { 439 439 t.Helper() 440 440 441 441 decoder := json.NewDecoder(resp.Body)
+9 -9
tests/integration/webfinger_test.go
··· 30 30 appURL, _ := url.Parse(setting.AppURL) 31 31 32 32 type webfingerLink struct { 33 - Rel string `json:"rel,omitempty"` 34 - Type string `json:"type,omitempty"` 35 - Href string `json:"href,omitempty"` 36 - Titles map[string]string `json:"titles,omitempty"` 37 - Properties map[string]interface{} `json:"properties,omitempty"` 33 + Rel string `json:"rel,omitempty"` 34 + Type string `json:"type,omitempty"` 35 + Href string `json:"href,omitempty"` 36 + Titles map[string]string `json:"titles,omitempty"` 37 + Properties map[string]any `json:"properties,omitempty"` 38 38 } 39 39 40 40 type webfingerJRD struct { 41 - Subject string `json:"subject,omitempty"` 42 - Aliases []string `json:"aliases,omitempty"` 43 - Properties map[string]interface{} `json:"properties,omitempty"` 44 - Links []*webfingerLink `json:"links,omitempty"` 41 + Subject string `json:"subject,omitempty"` 42 + Aliases []string `json:"aliases,omitempty"` 43 + Properties map[string]any `json:"properties,omitempty"` 44 + Links []*webfingerLink `json:"links,omitempty"` 45 45 } 46 46 47 47 session := loginUser(t, "user1")
+2 -2
tests/test_utils.go
··· 30 30 "github.com/stretchr/testify/assert" 31 31 ) 32 32 33 - func exitf(format string, args ...interface{}) { 33 + func exitf(format string, args ...any) { 34 34 fmt.Printf(format+"\n", args...) 35 35 os.Exit(1) 36 36 } ··· 247 247 } 248 248 249 249 // Printf takes a format and args and prints the string to os.Stdout 250 - func Printf(format string, args ...interface{}) { 250 + func Printf(format string, args ...any) { 251 251 testlogger.Printf(format, args...) 252 252 }