From dc9e08d39fe0cf5894d42f1798478f8dcef86c67 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sun, 31 Oct 2021 13:30:19 +0200 Subject: [PATCH] Stop using ioutil --- bridgestate.go | 4 ++-- config/config.go | 6 +++--- go.mod | 2 +- go.sum | 4 ++-- portal.go | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/bridgestate.go b/bridgestate.go index 4f6b6eb..bc5dc8e 100644 --- a/bridgestate.go +++ b/bridgestate.go @@ -21,7 +21,7 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "time" @@ -128,7 +128,7 @@ func sendPreparedBridgeStateRequest(logger log.Logger, req *http.Request) bool { } defer resp.Body.Close() if resp.StatusCode < 200 || resp.StatusCode > 299 { - respBody, _ := ioutil.ReadAll(resp.Body) + respBody, _ := io.ReadAll(resp.Body) if respBody != nil { respBody = bytes.ReplaceAll(respBody, []byte("\n"), []byte("\\n")) } diff --git a/config/config.go b/config/config.go index 661d6e4..1b59ebf 100644 --- a/config/config.go +++ b/config/config.go @@ -18,7 +18,7 @@ package config import ( "fmt" - "io/ioutil" + "os" "gopkg.in/yaml.v2" "maunium.net/go/mautrix/id" @@ -92,7 +92,7 @@ func (config *Config) CanDoublePuppet(userID id.UserID) bool { } func Load(path string) (*Config, error) { - data, err := ioutil.ReadFile(path) + data, err := os.ReadFile(path) if err != nil { return nil, err } @@ -111,7 +111,7 @@ func (config *Config) Save(path string) error { if err != nil { return err } - return ioutil.WriteFile(path, data, 0600) + return os.WriteFile(path, data, 0600) } func (config *Config) MakeAppService() (*appservice.AppService, error) { diff --git a/go.mod b/go.mod index 973d708..d73e019 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/mattn/go-sqlite3 v1.14.9 github.com/prometheus/client_golang v1.11.0 github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e - go.mau.fi/whatsmeow v0.0.0-20211029221633-b2fb3fda9a8c + go.mau.fi/whatsmeow v0.0.0-20211031112955-d9ede8b4ef4b golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d google.golang.org/protobuf v1.27.1 gopkg.in/yaml.v2 v2.4.0 diff --git a/go.sum b/go.sum index 785b073..9b89001 100644 --- a/go.sum +++ b/go.sum @@ -139,8 +139,8 @@ github.com/tidwall/sjson v1.2.3 h1:5+deguEhHSEjmuICXZ21uSSsXotWMA0orU783+Z7Cp8= github.com/tidwall/sjson v1.2.3/go.mod h1:5WdjKx3AQMvCJ4RG6/2UYT7dLrGvJUV1x4jdTAyGvZs= go.mau.fi/libsignal v0.0.0-20211024113310-f9fc6a1855f2 h1:xpQTMgJGGaF+c8jV/LA/FVXAPJxZbSAGeflOc+Ly6uQ= go.mau.fi/libsignal v0.0.0-20211024113310-f9fc6a1855f2/go.mod h1:3XlVlwOfp8f9Wri+C1D4ORqgUsN4ZvunJOoPjQMBhos= -go.mau.fi/whatsmeow v0.0.0-20211029221633-b2fb3fda9a8c h1:ZmmT3L8pMKLW3JhcP6Rt0dJg09N+20a8fROxr8MUKzg= -go.mau.fi/whatsmeow v0.0.0-20211029221633-b2fb3fda9a8c/go.mod h1:ODEmmqeUn9eBDQHFc1S902YA3YFLtmaBujYRRFl53jI= +go.mau.fi/whatsmeow v0.0.0-20211031112955-d9ede8b4ef4b h1:c9LwexDAVDsLNXcD4Vog5Y624sihnomf9XJl8ewtBl4= +go.mau.fi/whatsmeow v0.0.0-20211031112955-d9ede8b4ef4b/go.mod h1:ODEmmqeUn9eBDQHFc1S902YA3YFLtmaBujYRRFl53jI= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= diff --git a/portal.go b/portal.go index 1187ec1..10652eb 100644 --- a/portal.go +++ b/portal.go @@ -27,7 +27,7 @@ import ( "image/gif" "image/jpeg" "image/png" - "io/ioutil" + "io" "math" "mime" "net/http" @@ -1997,7 +1997,7 @@ func (portal *Portal) convertWebPtoPNG(webpImage []byte) ([]byte, error) { } func (portal *Portal) convertGifToVideo(gif []byte) ([]byte, error) { - dir, err := ioutil.TempDir("", "gif-convert-*") + dir, err := os.MkdirTemp("", "gif-convert-*") if err != nil { return nil, fmt.Errorf("failed to make temp dir: %w", err) } @@ -2036,7 +2036,7 @@ func (portal *Portal) convertGifToVideo(gif []byte) ([]byte, error) { _ = outputFile.Close() _ = os.Remove(outputFile.Name()) }() - mp4, err := ioutil.ReadAll(outputFile) + mp4, err := io.ReadAll(outputFile) if err != nil { return nil, fmt.Errorf("failed to read mp4 from output file: %w", err) }