remove io/ioutil.

This commit is contained in:
Miroslav Šedivý 2021-08-29 17:12:37 +02:00
parent 343b0c562a
commit 0501091c96
4 changed files with 9 additions and 10 deletions

View File

@ -3,7 +3,7 @@ package members
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"demodesk/neko/internal/types" "demodesk/neko/internal/types"
@ -16,7 +16,7 @@ type MemberBulkUpdatePayload struct {
} }
func (h *MembersHandler) membersBulkUpdate(w http.ResponseWriter, r *http.Request) { 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 { if err != nil {
utils.HttpInternalServerError(w, err) utils.HttpInternalServerError(w, err)
return return

View File

@ -2,7 +2,6 @@ package room
import ( import (
"io" "io"
"io/ioutil"
"net/http" "net/http"
"os" "os"
"path" "path"
@ -44,7 +43,7 @@ func (h *RoomHandler) uploadDrop(w http.ResponseWriter, r *http.Request) {
return return
} }
dir, err := ioutil.TempDir("", "neko-drop-*") dir, err := os.MkdirTemp("", "neko-drop-*")
if err != nil { if err != nil {
utils.HttpInternalServerError(w, err) utils.HttpInternalServerError(w, err)
return return
@ -108,7 +107,7 @@ func (h *RoomHandler) uploadDialogPost(w http.ResponseWriter, r *http.Request) {
return return
} }
dir, err := ioutil.TempDir("", "neko-dialog-*") dir, err := os.MkdirTemp("", "neko-dialog-*")
if err != nil { if err != nil {
utils.HttpInternalServerError(w, err) utils.HttpInternalServerError(w, err)
return return

View File

@ -2,7 +2,7 @@ package file
import ( import (
"encoding/json" "encoding/json"
"io/ioutil" "io"
"os" "os"
"demodesk/neko/internal/types" "demodesk/neko/internal/types"
@ -152,7 +152,7 @@ func (provider *MemberProviderCtx) deserialize() (map[string]MemberEntry, error)
return nil, err return nil, err
} }
raw, err := ioutil.ReadAll(file) raw, err := io.ReadAll(file)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -189,5 +189,5 @@ func (provider *MemberProviderCtx) serialize(data map[string]MemberEntry) error
return err return err
} }
return ioutil.WriteFile(provider.config.Path, raw, os.ModePerm) return os.WriteFile(provider.config.Path, raw, os.ModePerm)
} }

View File

@ -2,7 +2,7 @@ package utils
import ( import (
"bytes" "bytes"
"io/ioutil" "io"
"net/http" "net/http"
) )
@ -13,7 +13,7 @@ func HttpRequestGET(url string) (string, error) {
} }
defer rsp.Body.Close() defer rsp.Body.Close()
buf, err := ioutil.ReadAll(rsp.Body) buf, err := io.ReadAll(rsp.Body)
if err != nil { if err != nil {
return "", err return "", err
} }