From 3ccf397174f236a2dff7cfdcf5ca69aaa93a7fe5 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Tue, 30 Aug 2022 16:32:05 +0300 Subject: [PATCH] io/ioutil is deprecated since Go 1.16 --- cmd/sgblog-comment-add/mail.go | 3 +-- cmd/sgblog-comment-add/main.go | 4 ++-- cmd/sgblog/main.go | 4 ++-- common.go | 4 ++-- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/cmd/sgblog-comment-add/mail.go b/cmd/sgblog-comment-add/mail.go index 016da8c..6d1aa54 100644 --- a/cmd/sgblog-comment-add/mail.go +++ b/cmd/sgblog-comment-add/mail.go @@ -22,7 +22,6 @@ import ( "encoding/base64" "errors" "io" - "io/ioutil" "mime" "mime/multipart" "mime/quotedprintable" @@ -84,7 +83,7 @@ func parseEmail(msg *mail.Message) (subj string, body io.Reader, err error) { err = errors.New("no boundary string") return } - data, err := ioutil.ReadAll(msg.Body) + data, err := io.ReadAll(msg.Body) if err != nil { return } diff --git a/cmd/sgblog-comment-add/main.go b/cmd/sgblog-comment-add/main.go index a81d53d..186e56f 100644 --- a/cmd/sgblog-comment-add/main.go +++ b/cmd/sgblog-comment-add/main.go @@ -24,7 +24,7 @@ import ( "encoding/hex" "flag" "fmt" - "io/ioutil" + "io" "log" "mime" "net/mail" @@ -103,7 +103,7 @@ func main() { if err != nil { log.Fatal(err) } - body, err := ioutil.ReadAll(r) + body, err := io.ReadAll(r) if err != nil { log.Fatal(err) } diff --git a/cmd/sgblog/main.go b/cmd/sgblog/main.go index 7ee4e72..767850c 100644 --- a/cmd/sgblog/main.go +++ b/cmd/sgblog/main.go @@ -23,8 +23,8 @@ import ( "encoding/json" "flag" "fmt" - "io/ioutil" "log" + "os" "regexp" "strings" @@ -126,7 +126,7 @@ func initRepo(cfg *Cfg) (*plumbing.Hash, error) { } func readCfg(cfgPath string) (*Cfg, error) { - cfgRaw, err := ioutil.ReadFile(cfgPath) + cfgRaw, err := os.ReadFile(cfgPath) if err != nil { return nil, err } diff --git a/common.go b/common.go index 03ce423..1289dcc 100644 --- a/common.go +++ b/common.go @@ -4,7 +4,7 @@ package sgblog import ( "bytes" "fmt" - "io/ioutil" + "io" "sort" "text/scanner" @@ -81,7 +81,7 @@ func GetNote(repo *git.Repository, tree *object.Tree, what plumbing.Hash) []byte if err != nil { return nil } - data, err := ioutil.ReadAll(r) + data, err := io.ReadAll(r) if err != nil { return nil } -- 2.44.0