From 0501091c96373e56d55c47b9ee4e532b0e485219 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Sun, 29 Aug 2021 17:12:37 +0200 Subject: [PATCH] remove io/ioutil. --- internal/api/members/bluk.go | 4 ++-- internal/api/room/upload.go | 5 ++--- internal/member/file/provider.go | 6 +++--- internal/utils/request.go | 4 ++-- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/internal/api/members/bluk.go b/internal/api/members/bluk.go index 5d5edb20..cb1695c4 100644 --- a/internal/api/members/bluk.go +++ b/internal/api/members/bluk.go @@ -3,7 +3,7 @@ package members import ( "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "demodesk/neko/internal/types" @@ -16,7 +16,7 @@ type MemberBulkUpdatePayload struct { } func (h *MembersHandler) membersBulkUpdate(w http.ResponseWriter, r *http.Request) { - bytes, err := ioutil.ReadAll(r.Body) + bytes, err := io.ReadAll(r.Body) if err != nil { utils.HttpInternalServerError(w, err) return diff --git a/internal/api/room/upload.go b/internal/api/room/upload.go index 86dbac8f..58161271 100644 --- a/internal/api/room/upload.go +++ b/internal/api/room/upload.go @@ -2,7 +2,6 @@ package room import ( "io" - "io/ioutil" "net/http" "os" "path" @@ -44,7 +43,7 @@ func (h *RoomHandler) uploadDrop(w http.ResponseWriter, r *http.Request) { return } - dir, err := ioutil.TempDir("", "neko-drop-*") + dir, err := os.MkdirTemp("", "neko-drop-*") if err != nil { utils.HttpInternalServerError(w, err) return @@ -108,7 +107,7 @@ func (h *RoomHandler) uploadDialogPost(w http.ResponseWriter, r *http.Request) { return } - dir, err := ioutil.TempDir("", "neko-dialog-*") + dir, err := os.MkdirTemp("", "neko-dialog-*") if err != nil { utils.HttpInternalServerError(w, err) return diff --git a/internal/member/file/provider.go b/internal/member/file/provider.go index 39fbd74e..92a8c687 100644 --- a/internal/member/file/provider.go +++ b/internal/member/file/provider.go @@ -2,7 +2,7 @@ package file import ( "encoding/json" - "io/ioutil" + "io" "os" "demodesk/neko/internal/types" @@ -152,7 +152,7 @@ func (provider *MemberProviderCtx) deserialize() (map[string]MemberEntry, error) return nil, err } - raw, err := ioutil.ReadAll(file) + raw, err := io.ReadAll(file) if err != nil { return nil, err } @@ -189,5 +189,5 @@ func (provider *MemberProviderCtx) serialize(data map[string]MemberEntry) error return err } - return ioutil.WriteFile(provider.config.Path, raw, os.ModePerm) + return os.WriteFile(provider.config.Path, raw, os.ModePerm) } diff --git a/internal/utils/request.go b/internal/utils/request.go index 9ba77b01..7f860452 100644 --- a/internal/utils/request.go +++ b/internal/utils/request.go @@ -2,7 +2,7 @@ package utils import ( "bytes" - "io/ioutil" + "io" "net/http" ) @@ -13,7 +13,7 @@ func HttpRequestGET(url string) (string, error) { } defer rsp.Body.Close() - buf, err := ioutil.ReadAll(rsp.Body) + buf, err := io.ReadAll(rsp.Body) if err != nil { return "", err }