fix: fix staticcheck errors - errors.Is parameter order and deprecated ioutil

This commit is contained in:
2026-04-19 23:43:33 +08:00
parent 35e37a8142
commit 1685aa4428
11 changed files with 40 additions and 40 deletions
+1 -1
View File
@@ -385,7 +385,7 @@ func (api AccountApi) AccessTokenGetEndpoint(c echo.Context) error {
account, _ := GetCurrentAccount(c)
accessTokens, err := repository.AccessTokenRepository.FindByUserId(context.TODO(), account.ID)
if err != nil {
if errors.Is(gorm.ErrRecordNotFound, err) {
if errors.Is(err, gorm.ErrRecordNotFound) {
accessTokens = []model.AccessToken{}
} else {
return err
+1 -1
View File
@@ -16,7 +16,7 @@ import (
type BackupApi struct{}
func (api BackupApi) BackupExportEndpoint(c echo.Context) error {
err, backup := service.BackupService.Export()
backup, err := service.BackupService.Export()
if err != nil {
return err
}
+1 -1
View File
@@ -429,7 +429,7 @@ func (api SessionApi) SessionLsEndpoint(c echo.Context) error {
return Success(c, files)
} else if "rdp" == s.Protocol {
storageId := s.StorageId
err, files := service.StorageService.StorageLs(remoteDir, storageId)
files, err := service.StorageService.StorageLs(remoteDir, storageId)
if err != nil {
return err
}
+1 -1
View File
@@ -163,7 +163,7 @@ func (api StorageApi) StorageLsEndpoint(c echo.Context) error {
return err
}
remoteDir := c.FormValue("dir")
err, files := service.StorageService.StorageLs(remoteDir, storageId)
files, err := service.StorageService.StorageLs(remoteDir, storageId)
if err != nil {
return err
}
+1 -4
View File
@@ -120,10 +120,7 @@ func (api WorkCommandApi) CommandGetEndpoint(c echo.Context) (err error) {
func (api WorkCommandApi) checkPermission(c echo.Context, commandId string) bool {
command, err := repository.CommandRepository.FindById(context.Background(), commandId)
if err != nil {
if errors.Is(gorm.ErrRecordNotFound, err) {
return true
}
return false
return errors.Is(err, gorm.ErrRecordNotFound)
}
account, _ := api.GetCurrentAccount(c)
userId := account.ID