fix: 修复 golangci-lint errcheck 错误
This commit is contained in:
@@ -39,6 +39,6 @@ func (api AccessSettingApi) ShellAssistantEndpoint(c echo.Context) error {
|
|||||||
c.Response().Header().Set("Cache-Control", "no-cache")
|
c.Response().Header().Set("Cache-Control", "no-cache")
|
||||||
c.Response().Header().Set("Connection", "keep-alive")
|
c.Response().Header().Set("Connection", "keep-alive")
|
||||||
|
|
||||||
c.Response().Write([]byte("data: {\"success\":false,\"error\":\"Shell assistant is not configured\"}\n\n"))
|
_, _ = c.Response().Write([]byte("data: {\"success\":false,\"error\":\"Shell assistant is not configured\"}\n\n"))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -399,7 +399,7 @@ func (api AccountApi) AccessTokenGenEndpoint(c echo.Context) error {
|
|||||||
var req struct {
|
var req struct {
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
}
|
}
|
||||||
c.Bind(&req)
|
_ = c.Bind(&req)
|
||||||
if req.Type == "" {
|
if req.Type == "" {
|
||||||
req.Type = "api"
|
req.Type = "api"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ func (api AgentGatewayApi) UpdateSortEndpoint(c echo.Context) error {
|
|||||||
ctx := context.TODO()
|
ctx := context.TODO()
|
||||||
for _, item := range items {
|
for _, item := range items {
|
||||||
sortStr := strconv.Itoa(item.SortOrder * 100)
|
sortStr := strconv.Itoa(item.SortOrder * 100)
|
||||||
repository.AgentGatewayRepository.UpdateSort(ctx, item.ID, sortStr)
|
_ = repository.AgentGatewayRepository.UpdateSort(ctx, item.ID, sortStr)
|
||||||
}
|
}
|
||||||
return Success(c, nil)
|
return Success(c, nil)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ func (api AssetGroupApi) GroupsSetEndpoint(c echo.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
ctx := context.TODO()
|
ctx := context.TODO()
|
||||||
repository.AssetGroupRepository.DeleteByParentId(ctx, "")
|
_ = repository.AssetGroupRepository.DeleteByParentId(ctx, "")
|
||||||
for i, item := range req {
|
for i, item := range req {
|
||||||
name := ""
|
name := ""
|
||||||
if v, ok := item["name"].(string); ok {
|
if v, ok := item["name"].(string); ok {
|
||||||
@@ -45,7 +45,7 @@ func (api AssetGroupApi) GroupsSetEndpoint(c echo.Context) error {
|
|||||||
Sort: i,
|
Sort: i,
|
||||||
Created: time.Now().UnixMilli(),
|
Created: time.Now().UnixMilli(),
|
||||||
}
|
}
|
||||||
repository.AssetGroupRepository.Create(ctx, &group)
|
_ = repository.AssetGroupRepository.Create(ctx, &group)
|
||||||
if children, ok := item["children"].([]interface{}); ok {
|
if children, ok := item["children"].([]interface{}); ok {
|
||||||
saveChildren(ctx, children, group.ID)
|
saveChildren(ctx, children, group.ID)
|
||||||
}
|
}
|
||||||
@@ -56,8 +56,8 @@ func (api AssetGroupApi) GroupsSetEndpoint(c echo.Context) error {
|
|||||||
func (api AssetGroupApi) GroupsDeleteEndpoint(c echo.Context) error {
|
func (api AssetGroupApi) GroupsDeleteEndpoint(c echo.Context) error {
|
||||||
id := c.Param("id")
|
id := c.Param("id")
|
||||||
ctx := context.TODO()
|
ctx := context.TODO()
|
||||||
repository.AssetGroupRepository.DeleteByParentId(ctx, id)
|
_ = repository.AssetGroupRepository.DeleteByParentId(ctx, id)
|
||||||
repository.AssetGroupRepository.DeleteById(ctx, id)
|
_ = repository.AssetGroupRepository.DeleteById(ctx, id)
|
||||||
return Success(c, nil)
|
return Success(c, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ func saveChildren(ctx context.Context, children []interface{}, parentId string)
|
|||||||
Sort: i,
|
Sort: i,
|
||||||
Created: time.Now().UnixMilli(),
|
Created: time.Now().UnixMilli(),
|
||||||
}
|
}
|
||||||
repository.AssetGroupRepository.Create(ctx, &group)
|
_ = repository.AssetGroupRepository.Create(ctx, &group)
|
||||||
if subChildren, ok := m["children"].([]interface{}); ok {
|
if subChildren, ok := m["children"].([]interface{}); ok {
|
||||||
saveChildren(ctx, subChildren, group.ID)
|
saveChildren(ctx, subChildren, group.ID)
|
||||||
}
|
}
|
||||||
@@ -170,7 +170,7 @@ func (api AssetGroupApi) ChangeGroupEndpoint(c echo.Context) error {
|
|||||||
ctx := context.TODO()
|
ctx := context.TODO()
|
||||||
for _, id := range assetIds {
|
for _, id := range assetIds {
|
||||||
aid := id.(string)
|
aid := id.(string)
|
||||||
repository.AssetRepository.UpdateById(ctx, &model.Asset{ID: aid}, aid)
|
_ = repository.AssetRepository.UpdateById(ctx, &model.Asset{ID: aid}, aid)
|
||||||
}
|
}
|
||||||
_ = groupId
|
_ = groupId
|
||||||
return Success(c, nil)
|
return Success(c, nil)
|
||||||
@@ -195,7 +195,7 @@ func (api AssetGroupApi) ChangeGatewayEndpoint(c echo.Context) error {
|
|||||||
} else {
|
} else {
|
||||||
m["access_gateway_id"] = ""
|
m["access_gateway_id"] = ""
|
||||||
}
|
}
|
||||||
repository.AssetRepository.UpdateById(ctx, &model.Asset{ID: aid}, aid)
|
_ = repository.AssetRepository.UpdateById(ctx, &model.Asset{ID: aid}, aid)
|
||||||
_ = m
|
_ = m
|
||||||
}
|
}
|
||||||
_ = gatewayType
|
_ = gatewayType
|
||||||
@@ -229,7 +229,7 @@ func (api AssetGroupApi) SortEndpoint(c echo.Context) error {
|
|||||||
newSort = beforeSort + 1
|
newSort = beforeSort + 1
|
||||||
}
|
}
|
||||||
sortStr := strconv.Itoa(newSort)
|
sortStr := strconv.Itoa(newSort)
|
||||||
repository.AssetRepository.UpdateById(ctx, &model.Asset{ID: req.Id, Sort: newSort}, req.Id)
|
_ = repository.AssetRepository.UpdateById(ctx, &model.Asset{ID: req.Id, Sort: newSort}, req.Id)
|
||||||
_ = sortStr
|
_ = sortStr
|
||||||
return Success(c, nil)
|
return Success(c, nil)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ type JobLogDTO struct {
|
|||||||
func JobLogToDTO(log model.JobLog, jobType string) JobLogDTO {
|
func JobLogToDTO(log model.JobLog, jobType string) JobLogDTO {
|
||||||
var results []interface{}
|
var results []interface{}
|
||||||
if log.Results != "" {
|
if log.Results != "" {
|
||||||
json.Unmarshal([]byte(log.Results), &results)
|
_ = json.Unmarshal([]byte(log.Results), &results)
|
||||||
}
|
}
|
||||||
if results == nil {
|
if results == nil {
|
||||||
results = []interface{}{}
|
results = []interface{}{}
|
||||||
|
|||||||
+7
-8
@@ -174,8 +174,7 @@ func (api WebTerminalApi) SshEndpoint(c echo.Context) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if err := termHandler.WindowChange(winSize.Rows, winSize.Cols); err != nil {
|
_ = termHandler.WindowChange(winSize.Rows, winSize.Cols)
|
||||||
}
|
|
||||||
_ = repository.SessionRepository.UpdateWindowSizeById(ctx, winSize.Rows, winSize.Cols, sessionId)
|
_ = repository.SessionRepository.UpdateWindowSizeById(ctx, winSize.Rows, winSize.Cols, sessionId)
|
||||||
case Data:
|
case Data:
|
||||||
input := []byte(msg.Content)
|
input := []byte(msg.Content)
|
||||||
@@ -351,14 +350,14 @@ func (api WebTerminalApi) AccessTerminalEndpoint(c echo.Context) error {
|
|||||||
case Resize:
|
case Resize:
|
||||||
decodeString, _ := base64.StdEncoding.DecodeString(msg.Content)
|
decodeString, _ := base64.StdEncoding.DecodeString(msg.Content)
|
||||||
var winSize dto.WindowSize
|
var winSize dto.WindowSize
|
||||||
json.Unmarshal(decodeString, &winSize)
|
_ = json.Unmarshal(decodeString, &winSize)
|
||||||
termHandler.WindowChange(winSize.Rows, winSize.Cols)
|
_ = termHandler.WindowChange(winSize.Rows, winSize.Cols)
|
||||||
repository.SessionRepository.UpdateWindowSizeById(ctx, winSize.Rows, winSize.Cols, sessionId)
|
_ = repository.SessionRepository.UpdateWindowSizeById(ctx, winSize.Rows, winSize.Cols, sessionId)
|
||||||
case Data:
|
case Data:
|
||||||
termHandler.Write([]byte(msg.Content))
|
_ = termHandler.Write([]byte(msg.Content))
|
||||||
case Ping:
|
case Ping:
|
||||||
termHandler.SendRequest()
|
_ = termHandler.SendRequest()
|
||||||
termHandler.SendMessageToWebSocket(dto.NewMessage(Ping, msg.Content))
|
_ = termHandler.SendMessageToWebSocket(dto.NewMessage(Ping, msg.Content))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ func (api ToolsApi) PingEndpoint(c echo.Context) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Wait()
|
_ = cmd.Wait()
|
||||||
|
|
||||||
fmt.Fprintf(c.Response(), "event: done\ndata: completed\n\n")
|
fmt.Fprintf(c.Response(), "event: done\ndata: completed\n\n")
|
||||||
flusher.Flush()
|
flusher.Flush()
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ func (api WebsiteApi) GroupsSetEndpoint(c echo.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
ctx := context.TODO()
|
ctx := context.TODO()
|
||||||
repository.WebsiteGroupRepository.DeleteAll(ctx)
|
_ = repository.WebsiteGroupRepository.DeleteAll(ctx)
|
||||||
for i, item := range req {
|
for i, item := range req {
|
||||||
name := ""
|
name := ""
|
||||||
if v, ok := item["name"].(string); ok {
|
if v, ok := item["name"].(string); ok {
|
||||||
@@ -203,7 +203,7 @@ func (api WebsiteApi) GroupsSetEndpoint(c echo.Context) error {
|
|||||||
Sort: i,
|
Sort: i,
|
||||||
Created: common.NowJsonTime(),
|
Created: common.NowJsonTime(),
|
||||||
}
|
}
|
||||||
repository.WebsiteGroupRepository.Create(ctx, &group)
|
_ = repository.WebsiteGroupRepository.Create(ctx, &group)
|
||||||
if subChildren, ok := item["children"].([]interface{}); ok {
|
if subChildren, ok := item["children"].([]interface{}); ok {
|
||||||
saveWebsiteGroupChildren(ctx, subChildren, group.ID)
|
saveWebsiteGroupChildren(ctx, subChildren, group.ID)
|
||||||
}
|
}
|
||||||
@@ -230,7 +230,7 @@ func saveWebsiteGroupChildren(ctx context.Context, children []interface{}, paren
|
|||||||
Sort: i,
|
Sort: i,
|
||||||
Created: common.NowJsonTime(),
|
Created: common.NowJsonTime(),
|
||||||
}
|
}
|
||||||
repository.WebsiteGroupRepository.Create(ctx, &group)
|
_ = repository.WebsiteGroupRepository.Create(ctx, &group)
|
||||||
if subChildren, ok := m["children"].([]interface{}); ok {
|
if subChildren, ok := m["children"].([]interface{}); ok {
|
||||||
saveWebsiteGroupChildren(ctx, subChildren, group.ID)
|
saveWebsiteGroupChildren(ctx, subChildren, group.ID)
|
||||||
}
|
}
|
||||||
@@ -269,7 +269,7 @@ func (api WebsiteApi) ChangeGroupEndpoint(c echo.Context) error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
website.GroupId = req.GroupId
|
website.GroupId = req.GroupId
|
||||||
repository.WebsiteRepository.UpdateById(context.TODO(), &website, websiteId)
|
_ = repository.WebsiteRepository.UpdateById(context.TODO(), &website, websiteId)
|
||||||
}
|
}
|
||||||
return Success(c, nil)
|
return Success(c, nil)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user