fix: fix staticcheck errors - errors.Is parameter order and deprecated ioutil
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user