From 7fa2c2e4b67236de12e174e2bee964ccb9b72b18 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Tue, 6 Sep 2022 00:34:30 +0200 Subject: [PATCH] Lint: Replace deprecated io/ioutil package Signed-off-by: Knut Ahlers --- config.go | 3 +-- main.go | 4 ++-- twitch/twitch.go | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/config.go b/config.go index f86e985..547dbde 100644 --- a/config.go +++ b/config.go @@ -4,7 +4,6 @@ import ( _ "embed" "fmt" "io" - "io/ioutil" "os" "path" "sync" @@ -199,7 +198,7 @@ func patchConfig(filename, authorName, authorEmail, summary string, patcher func } func writeConfigToYAML(filename, authorName, authorEmail, summary string, obj *configFile) error { - tmpFile, err := ioutil.TempFile(path.Dir(filename), "twitch-bot-*.yaml") + tmpFile, err := os.CreateTemp(path.Dir(filename), "twitch-bot-*.yaml") if err != nil { return errors.Wrap(err, "opening tempfile") } diff --git a/main.go b/main.go index a6f26ba..ba32c6b 100644 --- a/main.go +++ b/main.go @@ -4,7 +4,7 @@ import ( "bytes" "context" "fmt" - "io/ioutil" + "io" "math" "net" "net/http" @@ -399,7 +399,7 @@ func checkExternalHTTP() { } defer resp.Body.Close() - data, err := ioutil.ReadAll(resp.Body) + data, err := io.ReadAll(resp.Body) if err != nil { log.WithError(err).Error("Unable to read selfcheck response") return diff --git a/twitch/twitch.go b/twitch/twitch.go index ccf4187..05a5352 100644 --- a/twitch/twitch.go +++ b/twitch/twitch.go @@ -7,7 +7,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "net/url" "strconv" @@ -805,7 +804,7 @@ func (c *Client) request(opts clientRequestOpts) error { } if opts.OKStatus != 0 && resp.StatusCode != opts.OKStatus { - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return newHTTPError(resp.StatusCode, nil, err) }