From 637c50c1a4bf7fb625d5f3caeef55a8ab7d83b8a Mon Sep 17 00:00:00 2001 From: Boyang Lyu Date: Thu, 8 Aug 2024 14:27:00 +0800 Subject: [PATCH] fix some coding style issues Signed-off-by: Boyang Lyu --- client/http/api.go | 2 +- client/http/interface.go | 16 ++++++++-------- .../pd-ctl/pdctl/command/gc_safepoint_command.go | 9 +-------- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/client/http/api.go b/client/http/api.go index 3f20005879f..90fa128defd 100644 --- a/client/http/api.go +++ b/client/http/api.go @@ -79,7 +79,7 @@ const ( Status = "/pd/api/v1/status" Version = "/pd/api/v1/version" operators = "/pd/api/v1/operators" - safepoint = "pd/api/v1/gc/safepoint" + safepoint = "/pd/api/v1/gc/safepoint" // Micro Service microServicePrefix = "/pd/api/v2/ms" // Keyspace diff --git a/client/http/interface.go b/client/http/interface.go index e947c59aeec..0d223fc9ccd 100644 --- a/client/http/interface.go +++ b/client/http/interface.go @@ -1029,28 +1029,28 @@ func (c *client) GetKeyspaceMetaByName(ctx context.Context, keyspaceName string) // GetGCSafePoint get the gc_safepoint func (c *client) GetGCSafePoint(ctx context.Context) (ListServiceGCSafepoint, error) { - var gcsafepoint ListServiceGCSafepoint + var gcSafePoint ListServiceGCSafepoint err := c.request(ctx, newRequestInfo(). WithName(GetGCSafePointName). WithURI(safepoint). WithMethod(http.MethodGet). - WithResp(&gcsafepoint)) + WithResp(&gcSafePoint)) if err != nil { - return gcsafepoint, err + return gcSafePoint, err } - return gcsafepoint, nil + return gcSafePoint, nil } -// DeleteGCSafePoint deletes a gc_safepoint -func (c *client) DeleteGCSafePoint(ctx context.Context, service_id string) (string, error) { +// DeleteGCSafePoint deletes a gc safepoint +func (c *client) DeleteGCSafePoint(ctx context.Context, serviceId string) (string, error) { var msg string err := c.request(ctx, newRequestInfo(). WithName(DeleteGCSafePointName). - WithURI(safepoint+"/"+service_id). + WithURI(safepoint+"/"+serviceId). WithMethod(http.MethodDelete). WithResp(&msg)) if err != nil { return msg, err } return msg, nil -} \ No newline at end of file +} diff --git a/tools/pd-ctl/pdctl/command/gc_safepoint_command.go b/tools/pd-ctl/pdctl/command/gc_safepoint_command.go index 496c870d9e1..e50b356993b 100644 --- a/tools/pd-ctl/pdctl/command/gc_safepoint_command.go +++ b/tools/pd-ctl/pdctl/command/gc_safepoint_command.go @@ -15,9 +15,7 @@ package command import ( - "encoding/json" "sort" - "github.com/spf13/cobra" ) @@ -52,12 +50,7 @@ func showSSPs(cmd *cobra.Command, _ []string) { sort.Slice(safepoint.ServiceGCSafepoints, func(i, j int) bool { return safepoint.ServiceGCSafepoints[i].SafePoint < safepoint.ServiceGCSafepoints[j].SafePoint }) - data, err := json.MarshalIndent(safepoint, "", " ") - if err != nil { - cmd.Printf("Failed to marshal service GC safepoint: %s\n", err) - return - } - jsonPrint(cmd, string(data)) + jsonPrint(cmd, safepoint) } func deleteSSP(cmd *cobra.Command, args []string) {