refactor: run Go modernize (#5002)

This commit is contained in:
Maximilian
2026-02-08 08:57:30 -06:00
committed by GitHub
parent 408aa78ed5
commit a704e86ac1
102 changed files with 322 additions and 352 deletions
+5 -5
View File
@@ -168,7 +168,7 @@ func (m *MockLibraryRepo) Count(options ...rest.QueryOptions) (int64, error) {
return m.CountAll()
}
func (m *MockLibraryRepo) Read(id string) (interface{}, error) {
func (m *MockLibraryRepo) Read(id string) (any, error) {
idInt, _ := strconv.Atoi(id)
mf, err := m.Get(idInt)
if errors.Is(err, model.ErrNotFound) {
@@ -177,7 +177,7 @@ func (m *MockLibraryRepo) Read(id string) (interface{}, error) {
return mf, err
}
func (m *MockLibraryRepo) ReadAll(options ...rest.QueryOptions) (interface{}, error) {
func (m *MockLibraryRepo) ReadAll(options ...rest.QueryOptions) (any, error) {
return m.GetAll()
}
@@ -185,13 +185,13 @@ func (m *MockLibraryRepo) EntityName() string {
return "library"
}
func (m *MockLibraryRepo) NewInstance() interface{} {
func (m *MockLibraryRepo) NewInstance() any {
return &model.Library{}
}
// REST Repository methods (string-based IDs)
func (m *MockLibraryRepo) Save(entity interface{}) (string, error) {
func (m *MockLibraryRepo) Save(entity any) (string, error) {
lib := entity.(*model.Library)
if m.Err != nil {
return "", m.Err
@@ -216,7 +216,7 @@ func (m *MockLibraryRepo) Save(entity interface{}) (string, error) {
return strconv.Itoa(lib.ID), nil
}
func (m *MockLibraryRepo) Update(id string, entity interface{}, cols ...string) error {
func (m *MockLibraryRepo) Update(id string, entity any, cols ...string) error {
lib := entity.(*model.Library)
if m.Err != nil {
return m.Err
+3 -3
View File
@@ -218,7 +218,7 @@ func (m *MockMediaFileRepo) Count(...rest.QueryOptions) (int64, error) {
return m.CountAll()
}
func (m *MockMediaFileRepo) Read(id string) (interface{}, error) {
func (m *MockMediaFileRepo) Read(id string) (any, error) {
mf, err := m.Get(id)
if errors.Is(err, model.ErrNotFound) {
return nil, rest.ErrNotFound
@@ -226,7 +226,7 @@ func (m *MockMediaFileRepo) Read(id string) (interface{}, error) {
return mf, err
}
func (m *MockMediaFileRepo) ReadAll(...rest.QueryOptions) (interface{}, error) {
func (m *MockMediaFileRepo) ReadAll(...rest.QueryOptions) (any, error) {
return m.GetAll()
}
@@ -234,7 +234,7 @@ func (m *MockMediaFileRepo) EntityName() string {
return "mediafile"
}
func (m *MockMediaFileRepo) NewInstance() interface{} {
func (m *MockMediaFileRepo) NewInstance() any {
return &model.MediaFile{}
}
+5 -5
View File
@@ -54,7 +54,7 @@ func (m *MockPluginRepo) Get(id string) (*model.Plugin, error) {
return nil, model.ErrNotFound
}
func (m *MockPluginRepo) Read(id string) (interface{}, error) {
func (m *MockPluginRepo) Read(id string) (any, error) {
p, err := m.Get(id)
if errors.Is(err, model.ErrNotFound) {
return nil, rest.ErrNotFound
@@ -151,21 +151,21 @@ func (m *MockPluginRepo) EntityName() string {
return "plugin"
}
func (m *MockPluginRepo) NewInstance() interface{} {
func (m *MockPluginRepo) NewInstance() any {
return &model.Plugin{}
}
func (m *MockPluginRepo) ReadAll(options ...rest.QueryOptions) (interface{}, error) {
func (m *MockPluginRepo) ReadAll(options ...rest.QueryOptions) (any, error) {
return m.GetAll()
}
func (m *MockPluginRepo) Save(entity interface{}) (string, error) {
func (m *MockPluginRepo) Save(entity any) (string, error) {
p := entity.(*model.Plugin)
err := m.Put(p)
return p.ID, err
}
func (m *MockPluginRepo) Update(id string, entity interface{}, cols ...string) error {
func (m *MockPluginRepo) Update(id string, entity any, cols ...string) error {
p := entity.(*model.Plugin)
p.ID = id
return m.Put(p)
+3 -3
View File
@@ -10,13 +10,13 @@ type MockShareRepo struct {
rest.Repository
rest.Persistable
Entity interface{}
Entity any
ID string
Cols []string
Error error
}
func (m *MockShareRepo) Save(entity interface{}) (string, error) {
func (m *MockShareRepo) Save(entity any) (string, error) {
if m.Error != nil {
return "", m.Error
}
@@ -28,7 +28,7 @@ func (m *MockShareRepo) Save(entity interface{}) (string, error) {
return s.ID, nil
}
func (m *MockShareRepo) Update(id string, entity interface{}, cols ...string) error {
func (m *MockShareRepo) Update(id string, entity any, cols ...string) error {
if m.Error != nil {
return m.Error
}
+2 -2
View File
@@ -149,7 +149,7 @@ func (u *MockedUserRepo) Delete(id string) error {
return model.ErrNotFound
}
func (u *MockedUserRepo) Save(entity interface{}) (string, error) {
func (u *MockedUserRepo) Save(entity any) (string, error) {
usr := entity.(*model.User)
if err := u.Put(usr); err != nil {
return "", err
@@ -157,7 +157,7 @@ func (u *MockedUserRepo) Save(entity interface{}) (string, error) {
return usr.ID, nil
}
func (u *MockedUserRepo) Update(id string, entity interface{}, cols ...string) error {
func (u *MockedUserRepo) Update(id string, entity any, cols ...string) error {
if u.Error != nil {
return u.Error
}