mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-25 11:22:16 +00:00
Replace interface{}
with any
(#25686)
Result of running `perl -p -i -e 's#interface\{\}#any#g' **/*` and `make fmt`.
Basically the same [as golang did](2580d0e08d
).
This commit is contained in:
parent
00dbba7f42
commit
88f835192d
233 changed files with 727 additions and 727 deletions
|
@ -24,7 +24,7 @@ type Comment struct {
|
|||
Updated time.Time
|
||||
Content string
|
||||
Reactions []*Reaction
|
||||
Meta map[string]interface{} `yaml:"meta,omitempty"` // see models/issues/comment.go for fields in Comment struct
|
||||
Meta map[string]any `yaml:"meta,omitempty"` // see models/issues/comment.go for fields in Comment struct
|
||||
}
|
||||
|
||||
// GetExternalName ExternalUserMigrated interface
|
||||
|
|
|
@ -34,4 +34,4 @@ type DownloaderFactory interface {
|
|||
}
|
||||
|
||||
// DownloaderContext has opaque information only relevant to a given downloader
|
||||
type DownloaderContext interface{}
|
||||
type DownloaderContext any
|
||||
|
|
|
@ -17,7 +17,7 @@ import (
|
|||
)
|
||||
|
||||
// Load project data from file, with optional validation
|
||||
func Load(filename string, data interface{}, validation bool) error {
|
||||
func Load(filename string, data any, validation bool) error {
|
||||
isJSON := strings.HasSuffix(filename, ".json")
|
||||
|
||||
bs, err := os.ReadFile(filename)
|
||||
|
@ -34,7 +34,7 @@ func Load(filename string, data interface{}, validation bool) error {
|
|||
return unmarshal(bs, data, isJSON)
|
||||
}
|
||||
|
||||
func unmarshal(bs []byte, data interface{}, isJSON bool) error {
|
||||
func unmarshal(bs []byte, data any, isJSON bool) error {
|
||||
if isJSON {
|
||||
return json.Unmarshal(bs, data)
|
||||
}
|
||||
|
@ -47,8 +47,8 @@ func getSchema(filename string) (*jsonschema.Schema, error) {
|
|||
return c.Compile(filename)
|
||||
}
|
||||
|
||||
func validate(bs []byte, datatype interface{}, isJSON bool) error {
|
||||
var v interface{}
|
||||
func validate(bs []byte, datatype any, isJSON bool) error {
|
||||
var v any
|
||||
err := unmarshal(bs, &v, isJSON)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -81,11 +81,11 @@ func validate(bs []byte, datatype interface{}, isJSON bool) error {
|
|||
return err
|
||||
}
|
||||
|
||||
func toStringKeys(val interface{}) (interface{}, error) {
|
||||
func toStringKeys(val any) (any, error) {
|
||||
var err error
|
||||
switch val := val.(type) {
|
||||
case map[string]interface{}:
|
||||
m := make(map[string]interface{})
|
||||
case map[string]any:
|
||||
m := make(map[string]any)
|
||||
for k, v := range val {
|
||||
m[k], err = toStringKeys(v)
|
||||
if err != nil {
|
||||
|
@ -93,8 +93,8 @@ func toStringKeys(val interface{}) (interface{}, error) {
|
|||
}
|
||||
}
|
||||
return m, nil
|
||||
case []interface{}:
|
||||
l := make([]interface{}, len(val))
|
||||
case []any:
|
||||
l := make([]any, len(val))
|
||||
for i, v := range val {
|
||||
l[i], err = toStringKeys(v)
|
||||
if err != nil {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
package migration
|
||||
|
||||
// Messenger is a formatting function similar to i18n.Tr
|
||||
type Messenger func(key string, args ...interface{})
|
||||
type Messenger func(key string, args ...any)
|
||||
|
||||
// NilMessenger represents an empty formatting function
|
||||
func NilMessenger(string, ...interface{}) {}
|
||||
func NilMessenger(string, ...any) {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue