Skip to content

Commit

Permalink
Replace deprecated 'ioutil' with io (#12)
Browse files Browse the repository at this point in the history
ioutil seems to be deprecated since Go 1.16. It can simply be replaced with 'io.ReadAll' (in this case).
manschwa authored Feb 27, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 95bf374 commit 7cbf52f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
@@ -20,8 +20,8 @@ import (
"embed"
"encoding/json"
"errors"
"io"
"io/fs"
"io/ioutil"
"log"
"net/http"
"os"
@@ -125,12 +125,14 @@ func setupRouter() *gin.Engine {
c.JSON(http.StatusBadGateway, nil)
return
}

if resp.StatusCode != 200 {
log.Println(resp)
c.JSON(resp.StatusCode, nil)
return
}
bodyText, err := ioutil.ReadAll(resp.Body)

bodyText, err := io.ReadAll(resp.Body)
s := string(bodyText)
var result AgentStateResult
json.Unmarshal([]byte(s), &result)

0 comments on commit 7cbf52f

Please sign in to comment.