]> Cypherpunks.ru repositories - goircd.git/commitdiff
io/ioutil is deprecated since Go 1.16
authorSergey Matveev <stargrave@stargrave.org>
Tue, 30 Aug 2022 13:26:20 +0000 (16:26 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Tue, 30 Aug 2022 13:26:20 +0000 (16:26 +0300)
client.go
daemon_test.go
goircd.go

index 6e82e1409794db633ba4eca3b27cf7c31994cc9f..bd65d37915e99f02417a44182535db6fd5ec2180 100644 (file)
--- a/client.go
+++ b/client.go
@@ -23,9 +23,9 @@ import (
        "crypto/subtle"
        "encoding/hex"
        "fmt"
        "crypto/subtle"
        "encoding/hex"
        "fmt"
-       "io/ioutil"
        "log"
        "net"
        "log"
        "net"
+       "os"
        "regexp"
        "sort"
        "strings"
        "regexp"
        "sort"
        "strings"
@@ -233,7 +233,7 @@ func (c *Client) SendMotd() {
                c.ReplyNicknamed("422", "MOTD File is missing")
                return
        }
                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")
        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
                        }
                                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
                        if err != nil {
                                log.Fatalf("can not read passwords file %s: %s", *passwords, err)
                                return
index bcd8326badd139d4686bc129fa1676f25f5ed2c6..db8401351831c3026d2e391f3719ba3bf1800e13 100644 (file)
@@ -18,7 +18,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 package main
 
 import (
 package main
 
 import (
-       "io/ioutil"
        "os"
        "strings"
        "testing"
        "os"
        "strings"
        "testing"
@@ -113,7 +112,7 @@ func TestRegistrationWorkflow(t *testing.T) {
 }
 
 func TestMotd(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)
        }
        if err != nil {
                t.Fatalf("can not create temporary file: %v", err)
        }
index ddf81286a1ff07cf6daa982fc571a134f5e096a7..6168eaf62d1dd4fa416cb3f9f7b41681fa5d7e68 100644 (file)
--- a/goircd.go
+++ b/goircd.go
@@ -20,7 +20,6 @@ package main
 import (
        "crypto/tls"
        "flag"
 import (
        "crypto/tls"
        "flag"
-       "io/ioutil"
        "log"
        "net"
        "os"
        "log"
        "net"
        "os"
@@ -144,7 +143,7 @@ func main() {
                        log.Fatalln("can not read statedir", err)
                }
                for _, state := range states {
                        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",
                        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")
                        }
                        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 {
                        if err == nil {
                                room.key = strings.TrimRight(string(buf), "\n")
                        } else {
@@ -178,7 +177,7 @@ func main() {
                                }
 
                                topicPath := path.Join(statePath, StateTopicFilename)
                                }
 
                                topicPath := path.Join(statePath, StateTopicFilename)
-                               if err := ioutil.WriteFile(
+                               if err := os.WriteFile(
                                        topicPath,
                                        []byte(event.topic+"\n"),
                                        permStateFile,
                                        topicPath,
                                        []byte(event.topic+"\n"),
                                        permStateFile,
@@ -188,7 +187,7 @@ func main() {
                                }
 
                                keyPath := path.Join(statePath, StateKeyFilename)
                                }
 
                                keyPath := path.Join(statePath, StateKeyFilename)
-                               if err := ioutil.WriteFile(
+                               if err := os.WriteFile(
                                        keyPath,
                                        []byte(event.key+"\n"),
                                        permStateFile,
                                        keyPath,
                                        []byte(event.key+"\n"),
                                        permStateFile,