fix: golint

This commit is contained in:
debugtalk
2022-07-26 15:26:39 +08:00
parent ed145c6428
commit 7a94a7860c

View File

@@ -9,9 +9,10 @@ import (
"net/http" "net/http"
"strings" "strings"
"github.com/mitchellh/mapstructure"
"github.com/httprunner/httprunner/v4/hrp/internal/boomer" "github.com/httprunner/httprunner/v4/hrp/internal/boomer"
"github.com/httprunner/httprunner/v4/hrp/internal/json" "github.com/httprunner/httprunner/v4/hrp/internal/json"
"github.com/mitchellh/mapstructure"
) )
const jsonContentType = "application/json; encoding=utf-8" const jsonContentType = "application/json; encoding=utf-8"
@@ -134,16 +135,14 @@ type CommonResponseBody struct {
ServerStatus ServerStatus
} }
type APIGetWorkersRequestBody struct { type APIGetWorkersRequestBody struct{}
}
type APIGetWorkersResponseBody struct { type APIGetWorkersResponseBody struct {
ServerStatus ServerStatus
Data []boomer.WorkerNode `json:"data"` Data []boomer.WorkerNode `json:"data"`
} }
type APIGetMasterRequestBody struct { type APIGetMasterRequestBody struct{}
}
type APIGetMasterResponseBody struct { type APIGetMasterResponseBody struct {
ServerStatus ServerStatus
@@ -204,7 +203,7 @@ func (api *apiHandler) Start(w http.ResponseWriter, r *http.Request) {
for k := range req.Other { for k := range req.Other {
keys = append(keys, k) keys = append(keys, k)
} }
err = errors.New(fmt.Sprintf("failed to recognize params: %v", keys)) err = fmt.Errorf("failed to recognize params: %v", keys)
return return
} }
@@ -258,7 +257,7 @@ func (api *apiHandler) ReBalance(w http.ResponseWriter, r *http.Request) {
for k := range req.Other { for k := range req.Other {
keys = append(keys, k) keys = append(keys, k)
} }
err = errors.New(fmt.Sprintf("failed to recognize params: %v", keys)) err = fmt.Errorf("failed to recognize params: %v", keys)
return return
} }
@@ -370,7 +369,7 @@ func (b *HRPBoomer) StartServer(ctx context.Context, addr string) {
} }
}() }()
log.Println(fmt.Sprintf("starting HTTP server (%v), please use the API to control master", server.Addr)) log.Printf("starting HTTP server (%v), please use the API to control master", server.Addr)
err := server.ListenAndServe() err := server.ListenAndServe()
if err != nil { if err != nil {
if err == http.ErrServerClosed { if err == http.ErrServerClosed {