From: Sergey Matveev Date: Tue, 30 Aug 2022 13:26:20 +0000 (+0300) Subject: io/ioutil is deprecated since Go 1.16 X-Git-Tag: v1.10.0~7 X-Git-Url: http://www.git.cypherpunks.ru/?p=goircd.git;a=commitdiff_plain;h=6f9d7fae374e5ada6c33f585db748f23fbc49f91 io/ioutil is deprecated since Go 1.16 --- diff --git a/client.go b/client.go index 6e82e14..bd65d37 100644 --- a/client.go +++ b/client.go @@ -23,9 +23,9 @@ import ( "crypto/subtle" "encoding/hex" "fmt" - "io/ioutil" "log" "net" + "os" "regexp" "sort" "strings" @@ -233,7 +233,7 @@ func (c *Client) SendMotd() { c.ReplyNicknamed("422", "MOTD File is missing") return } - motdText, err := ioutil.ReadFile(*motd) + motdText, err := os.ReadFile(*motd) if err != nil { log.Printf("can not read motd file %s: %v", *motd, err) c.ReplyNicknamed("422", "Error reading MOTD File") @@ -418,7 +418,7 @@ func (c *Client) Register(cmd string, cols []string) { c.Close() return } - contents, err := ioutil.ReadFile(*passwords) + contents, err := os.ReadFile(*passwords) if err != nil { log.Fatalf("can not read passwords file %s: %s", *passwords, err) return diff --git a/daemon_test.go b/daemon_test.go index bcd8326..db84013 100644 --- a/daemon_test.go +++ b/daemon_test.go @@ -18,7 +18,6 @@ along with this program. If not, see . package main import ( - "io/ioutil" "os" "strings" "testing" @@ -113,7 +112,7 @@ func TestRegistrationWorkflow(t *testing.T) { } func TestMotd(t *testing.T) { - fd, err := ioutil.TempFile("", "motd") + fd, err := os.CreateTemp("", "motd") if err != nil { t.Fatalf("can not create temporary file: %v", err) } diff --git a/goircd.go b/goircd.go index ddf8128..6168eaf 100644 --- a/goircd.go +++ b/goircd.go @@ -20,7 +20,6 @@ package main import ( "crypto/tls" "flag" - "io/ioutil" "log" "net" "os" @@ -144,7 +143,7 @@ func main() { log.Fatalln("can not read statedir", err) } for _, state := range states { - buf, err := ioutil.ReadFile(path.Join(state, StateTopicFilename)) + buf, err := os.ReadFile(path.Join(state, StateTopicFilename)) if err != nil { log.Fatalf( "can not read state %s/%s: %v", @@ -153,7 +152,7 @@ func main() { } room := RoomRegister(path.Base(state)) room.topic = strings.TrimRight(string(buf), "\n") - buf, err = ioutil.ReadFile(path.Join(state, StateKeyFilename)) + buf, err = os.ReadFile(path.Join(state, StateKeyFilename)) if err == nil { room.key = strings.TrimRight(string(buf), "\n") } else { @@ -178,7 +177,7 @@ func main() { } topicPath := path.Join(statePath, StateTopicFilename) - if err := ioutil.WriteFile( + if err := os.WriteFile( topicPath, []byte(event.topic+"\n"), permStateFile, @@ -188,7 +187,7 @@ func main() { } keyPath := path.Join(statePath, StateKeyFilename) - if err := ioutil.WriteFile( + if err := os.WriteFile( keyPath, []byte(event.key+"\n"), permStateFile,