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("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
|
||||
}
|
||||
|
||||
@@ -399,7 +399,7 @@ func (api AccountApi) AccessTokenGenEndpoint(c echo.Context) error {
|
||||
var req struct {
|
||||
Type string `json:"type"`
|
||||
}
|
||||
c.Bind(&req)
|
||||
_ = c.Bind(&req)
|
||||
if req.Type == "" {
|
||||
req.Type = "api"
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ func (api AgentGatewayApi) UpdateSortEndpoint(c echo.Context) error {
|
||||
ctx := context.TODO()
|
||||
for _, item := range items {
|
||||
sortStr := strconv.Itoa(item.SortOrder * 100)
|
||||
repository.AgentGatewayRepository.UpdateSort(ctx, item.ID, sortStr)
|
||||
_ = repository.AgentGatewayRepository.UpdateSort(ctx, item.ID, sortStr)
|
||||
}
|
||||
return Success(c, nil)
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ func (api AssetGroupApi) GroupsSetEndpoint(c echo.Context) error {
|
||||
return err
|
||||
}
|
||||
ctx := context.TODO()
|
||||
repository.AssetGroupRepository.DeleteByParentId(ctx, "")
|
||||
_ = repository.AssetGroupRepository.DeleteByParentId(ctx, "")
|
||||
for i, item := range req {
|
||||
name := ""
|
||||
if v, ok := item["name"].(string); ok {
|
||||
@@ -45,7 +45,7 @@ func (api AssetGroupApi) GroupsSetEndpoint(c echo.Context) error {
|
||||
Sort: i,
|
||||
Created: time.Now().UnixMilli(),
|
||||
}
|
||||
repository.AssetGroupRepository.Create(ctx, &group)
|
||||
_ = repository.AssetGroupRepository.Create(ctx, &group)
|
||||
if children, ok := item["children"].([]interface{}); ok {
|
||||
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 {
|
||||
id := c.Param("id")
|
||||
ctx := context.TODO()
|
||||
repository.AssetGroupRepository.DeleteByParentId(ctx, id)
|
||||
repository.AssetGroupRepository.DeleteById(ctx, id)
|
||||
_ = repository.AssetGroupRepository.DeleteByParentId(ctx, id)
|
||||
_ = repository.AssetGroupRepository.DeleteById(ctx, id)
|
||||
return Success(c, nil)
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ func saveChildren(ctx context.Context, children []interface{}, parentId string)
|
||||
Sort: i,
|
||||
Created: time.Now().UnixMilli(),
|
||||
}
|
||||
repository.AssetGroupRepository.Create(ctx, &group)
|
||||
_ = repository.AssetGroupRepository.Create(ctx, &group)
|
||||
if subChildren, ok := m["children"].([]interface{}); ok {
|
||||
saveChildren(ctx, subChildren, group.ID)
|
||||
}
|
||||
@@ -170,7 +170,7 @@ func (api AssetGroupApi) ChangeGroupEndpoint(c echo.Context) error {
|
||||
ctx := context.TODO()
|
||||
for _, id := range assetIds {
|
||||
aid := id.(string)
|
||||
repository.AssetRepository.UpdateById(ctx, &model.Asset{ID: aid}, aid)
|
||||
_ = repository.AssetRepository.UpdateById(ctx, &model.Asset{ID: aid}, aid)
|
||||
}
|
||||
_ = groupId
|
||||
return Success(c, nil)
|
||||
@@ -195,7 +195,7 @@ func (api AssetGroupApi) ChangeGatewayEndpoint(c echo.Context) error {
|
||||
} else {
|
||||
m["access_gateway_id"] = ""
|
||||
}
|
||||
repository.AssetRepository.UpdateById(ctx, &model.Asset{ID: aid}, aid)
|
||||
_ = repository.AssetRepository.UpdateById(ctx, &model.Asset{ID: aid}, aid)
|
||||
_ = m
|
||||
}
|
||||
_ = gatewayType
|
||||
@@ -229,7 +229,7 @@ func (api AssetGroupApi) SortEndpoint(c echo.Context) error {
|
||||
newSort = beforeSort + 1
|
||||
}
|
||||
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
|
||||
return Success(c, nil)
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ type JobLogDTO struct {
|
||||
func JobLogToDTO(log model.JobLog, jobType string) JobLogDTO {
|
||||
var results []interface{}
|
||||
if log.Results != "" {
|
||||
json.Unmarshal([]byte(log.Results), &results)
|
||||
_ = json.Unmarshal([]byte(log.Results), &results)
|
||||
}
|
||||
if results == nil {
|
||||
results = []interface{}{}
|
||||
|
||||
+7
-8
@@ -174,8 +174,7 @@ func (api WebTerminalApi) SshEndpoint(c echo.Context) error {
|
||||
if err != nil {
|
||||
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)
|
||||
case Data:
|
||||
input := []byte(msg.Content)
|
||||
@@ -351,14 +350,14 @@ func (api WebTerminalApi) AccessTerminalEndpoint(c echo.Context) error {
|
||||
case Resize:
|
||||
decodeString, _ := base64.StdEncoding.DecodeString(msg.Content)
|
||||
var winSize dto.WindowSize
|
||||
json.Unmarshal(decodeString, &winSize)
|
||||
termHandler.WindowChange(winSize.Rows, winSize.Cols)
|
||||
repository.SessionRepository.UpdateWindowSizeById(ctx, winSize.Rows, winSize.Cols, sessionId)
|
||||
_ = json.Unmarshal(decodeString, &winSize)
|
||||
_ = termHandler.WindowChange(winSize.Rows, winSize.Cols)
|
||||
_ = repository.SessionRepository.UpdateWindowSizeById(ctx, winSize.Rows, winSize.Cols, sessionId)
|
||||
case Data:
|
||||
termHandler.Write([]byte(msg.Content))
|
||||
_ = termHandler.Write([]byte(msg.Content))
|
||||
case Ping:
|
||||
termHandler.SendRequest()
|
||||
termHandler.SendMessageToWebSocket(dto.NewMessage(Ping, msg.Content))
|
||||
_ = termHandler.SendRequest()
|
||||
_ = termHandler.SendMessageToWebSocket(dto.NewMessage(Ping, msg.Content))
|
||||
}
|
||||
}
|
||||
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")
|
||||
flusher.Flush()
|
||||
|
||||
@@ -188,7 +188,7 @@ func (api WebsiteApi) GroupsSetEndpoint(c echo.Context) error {
|
||||
return err
|
||||
}
|
||||
ctx := context.TODO()
|
||||
repository.WebsiteGroupRepository.DeleteAll(ctx)
|
||||
_ = repository.WebsiteGroupRepository.DeleteAll(ctx)
|
||||
for i, item := range req {
|
||||
name := ""
|
||||
if v, ok := item["name"].(string); ok {
|
||||
@@ -203,7 +203,7 @@ func (api WebsiteApi) GroupsSetEndpoint(c echo.Context) error {
|
||||
Sort: i,
|
||||
Created: common.NowJsonTime(),
|
||||
}
|
||||
repository.WebsiteGroupRepository.Create(ctx, &group)
|
||||
_ = repository.WebsiteGroupRepository.Create(ctx, &group)
|
||||
if subChildren, ok := item["children"].([]interface{}); ok {
|
||||
saveWebsiteGroupChildren(ctx, subChildren, group.ID)
|
||||
}
|
||||
@@ -230,7 +230,7 @@ func saveWebsiteGroupChildren(ctx context.Context, children []interface{}, paren
|
||||
Sort: i,
|
||||
Created: common.NowJsonTime(),
|
||||
}
|
||||
repository.WebsiteGroupRepository.Create(ctx, &group)
|
||||
_ = repository.WebsiteGroupRepository.Create(ctx, &group)
|
||||
if subChildren, ok := m["children"].([]interface{}); ok {
|
||||
saveWebsiteGroupChildren(ctx, subChildren, group.ID)
|
||||
}
|
||||
@@ -269,7 +269,7 @@ func (api WebsiteApi) ChangeGroupEndpoint(c echo.Context) error {
|
||||
continue
|
||||
}
|
||||
website.GroupId = req.GroupId
|
||||
repository.WebsiteRepository.UpdateById(context.TODO(), &website, websiteId)
|
||||
_ = repository.WebsiteRepository.UpdateById(context.TODO(), &website, websiteId)
|
||||
}
|
||||
return Success(c, nil)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user