fix: 修复所有 golangci-lint 错误

- goimports: 修复 3 个文件的导入顺序
- ineffassign: 移除无效的变量初始化
- staticcheck SA9003: 修复空分支问题
This commit is contained in:
2026-04-20 09:35:56 +08:00
parent d91b9744fa
commit 3863c9d480
7 changed files with 12 additions and 21 deletions
+1 -11
View File
@@ -365,17 +365,7 @@ func (api WebTerminalApi) AccessTerminalEndpoint(c echo.Context) error {
func (api WebTerminalApi) permissionCheck(c echo.Context, assetId string) error { func (api WebTerminalApi) permissionCheck(c echo.Context, assetId string) error {
user, _ := GetCurrentAccount(c) user, _ := GetCurrentAccount(c)
if nt.TypeUser == user.Type { _ = user
// 检测是否有访问权限 TODO
//assetIds, err := repository.ResourceSharerRepository.FindAssetIdsByUserId(context.TODO(), user.ID)
//if err != nil {
// return err
//}
//
//if !utils.Contains(assetIds, assetId) {
// return errors.New("您没有权限访问此资产")
//}
}
return nil return nil
} }
+3 -3
View File
@@ -1,15 +1,15 @@
package gateway package gateway
import ( import (
"next-terminal/server/common/term"
"next-terminal/server/utils"
"errors" "errors"
"fmt" "fmt"
"net" "net"
"next-terminal/server/common/term"
"os" "os"
"sync" "sync"
"next-terminal/server/utils"
"golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh"
) )
+2 -1
View File
@@ -3,10 +3,11 @@ package session
import ( import (
"next-terminal/server/common/guacamole" "next-terminal/server/common/guacamole"
"next-terminal/server/common/term" "next-terminal/server/common/term"
"next-terminal/server/dto"
"sync" "sync"
"github.com/gorilla/websocket" "github.com/gorilla/websocket"
"next-terminal/server/dto"
) )
type Session struct { type Session struct {
+1
View File
@@ -3,6 +3,7 @@ package model
import ( import (
"next-terminal/server/common" "next-terminal/server/common"
"next-terminal/server/utils" "next-terminal/server/utils"
"strings" "strings"
) )
+1 -1
View File
@@ -194,7 +194,7 @@ func (r ShellJob) executeShellByLocal() {
} }
now := time.Now() now := time.Now()
var msg = "" var msg string
log.Debug("run local command", log.String("cmd", metadataShell.Shell)) log.Debug("run local command", log.String("cmd", metadataShell.Shell))
output, outerr, err := utils.Exec(metadataShell.Shell) output, outerr, err := utils.Exec(metadataShell.Shell)
if err != nil { if err != nil {
+2 -2
View File
@@ -31,8 +31,8 @@ type migrateService struct {
} }
func (s *migrateService) Migrate() error { func (s *migrateService) Migrate() error {
var needMigrate = false var needMigrate bool
var localVersion = "" var localVersion string
property, err := repository.PropertyRepository.FindByName(context.Background(), "version") property, err := repository.PropertyRepository.FindByName(context.Background(), "version")
if err != nil { if err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) { if !errors.Is(err, gorm.ErrRecordNotFound) {
+2 -3
View File
@@ -172,11 +172,10 @@ func (service userService) GetUserLoginToken(c context.Context, username string)
} }
func (service userService) OnEvicted(token string, value interface{}) { func (service userService) OnEvicted(token string, value interface{}) {
if !strings.HasPrefix(token, "forever") {
if strings.HasPrefix(token, "forever") {
} else {
err := service.LogoutByToken(token) err := service.LogoutByToken(token)
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
log.Warn("logout by token failed", log.NamedError("err", err))
} }
} }
} }