From ca9b9fddf1ade89004c0daf40e28c0a90528d850 Mon Sep 17 00:00:00 2001 From: Vit Listik Date: Sat, 19 Nov 2022 18:05:23 +0100 Subject: [PATCH] update depreacted ioutil call --- cmd/daemon/dump.go | 8 ++++---- cmd/daemon/record.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/daemon/dump.go b/cmd/daemon/dump.go index c488996..d76db70 100644 --- a/cmd/daemon/dump.go +++ b/cmd/daemon/dump.go @@ -3,7 +3,7 @@ package main import ( "encoding/json" "github.com/curusarn/resh/internal/histcli" - "io/ioutil" + "io" "net/http" "github.com/curusarn/resh/internal/msg" @@ -18,17 +18,17 @@ type dumpHandler struct { func (h *dumpHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { sugar := h.sugar.With(zap.String("endpoint", "/dump")) sugar.Debugw("Handling request, reading body ...") - jsn, err := ioutil.ReadAll(r.Body) + jsn, err := io.ReadAll(r.Body) if err != nil { sugar.Errorw("Error reading body", "error", err) return } - sugar.Debugw("Unmarshaling record ...") + sugar.Debugw("Unmarshalling record ...") mess := msg.CliMsg{} err = json.Unmarshal(jsn, &mess) if err != nil { - sugar.Errorw("Error during unmarshaling", + sugar.Errorw("Error during unmarshalling", "error", err, "payload", jsn, ) diff --git a/cmd/daemon/record.go b/cmd/daemon/record.go index 34e9c1c..1684129 100644 --- a/cmd/daemon/record.go +++ b/cmd/daemon/record.go @@ -2,7 +2,7 @@ package main import ( "encoding/json" - "io/ioutil" + "io" "net/http" "github.com/curusarn/resh/internal/recordint" @@ -25,7 +25,7 @@ func (h *recordHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { sugar := h.sugar.With(zap.String("endpoint", "/record")) sugar.Debugw("Handling request, sending response, reading body ...") w.Write([]byte("OK\n")) - jsn, err := ioutil.ReadAll(r.Body) + jsn, err := io.ReadAll(r.Body) // run rest of the handler as goroutine to prevent any hangups go func() { if err != nil {