From f50f90c6a5cc1731b643523e4426794865eb14c8 Mon Sep 17 00:00:00 2001 From: Enderson Maia Date: Tue, 10 Sep 2024 09:59:14 -0300 Subject: [PATCH] chore: fix golang warnings - using io instead of io/ioutils - add field name to Struct literal at FinishRequest - using for {} instead of for true {} - add missing formmating directive for fmt.Errorf --- go/src/dapp.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/go/src/dapp.go b/go/src/dapp.go index 0f4de38..cb97db1 100644 --- a/go/src/dapp.go +++ b/go/src/dapp.go @@ -3,7 +3,7 @@ package main import ( "encoding/json" "fmt" - "io/ioutil" + "io" "log" "os" "strconv" @@ -41,13 +41,13 @@ func Handler(response *rollups.FinishResponse) error { case "advance_state": data := new(rollups.AdvanceResponse) if err = json.Unmarshal(response.Data, data); err != nil { - return fmt.Errorf("Handler: Error unmarshaling advance:", err) + return fmt.Errorf("Handler: Error unmarshaling advance: %s", err) } err = HandleAdvance(data) case "inspect_state": data := new(rollups.InspectResponse) if err = json.Unmarshal(response.Data, data); err != nil { - return fmt.Errorf("Handler: Error unmarshaling inspect:", err) + return fmt.Errorf("Handler: Error unmarshaling inspect: %s", err) } err = HandleInspect(data) } @@ -55,9 +55,9 @@ func Handler(response *rollups.FinishResponse) error { } func main() { - finish := rollups.FinishRequest{"accept"} + finish := rollups.FinishRequest{Status: "accept"} - for true { + for { infolog.Println("Sending finish") res, err := rollups.SendFinish(&finish) if err != nil { @@ -69,7 +69,7 @@ func main() { infolog.Println("No pending rollup request, trying again") } else { - resBody, err := ioutil.ReadAll(res.Body) + resBody, err := io.ReadAll(res.Body) if err != nil { errlog.Panicln("Error: could not read response body: ", err) }