deprecations

This commit is contained in:
ycc 2022-12-19 12:15:10 +01:00
parent bf901a7aa3
commit c6ec65f3fa
4 changed files with 10 additions and 10 deletions

View File

@ -7,7 +7,7 @@ import (
"image" "image"
"image/color" "image/color"
"image/png" "image/png"
"io/ioutil" "io"
"log" "log"
"math" "math"
"os" "os"
@ -71,7 +71,7 @@ func NewContactCardFromCompressed(compressed []byte) (*ContactCard, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
output, err := ioutil.ReadAll(gzreader) output, err := io.ReadAll(gzreader)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -94,7 +94,7 @@ func (contact *ContactCard) WriteCompressed(filename string) error {
if err != nil { if err != nil {
return err return err
} }
err = ioutil.WriteFile(filename, out, 0600) err = os.WriteFile(filename, out, 0600)
if err != nil { if err != nil {
return err return err
} }

View File

@ -3,7 +3,7 @@ package meowlib_test
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "os"
"testing" "testing"
"forge.redroom.link/yves/meowlib" "forge.redroom.link/yves/meowlib"
@ -74,7 +74,7 @@ func TestEndToEnd(t *testing.T) {
} }
a, _ = json.Marshal(Me) a, _ = json.Marshal(Me)
ioutil.WriteFile("id.json", a, 0644) os.WriteFile("id.json", a, 0644)
fmt.Println(string(a)) fmt.Println(string(a))
///////////////////////////////////// /////////////////////////////////////
// Create a message to that friend // // Create a message to that friend //

View File

@ -13,7 +13,7 @@ func (msg *UserMessage) AddFile(filename string, maxMessageSize int64) error {
return err return err
} }
if fi.Size() > maxMessageSize { if fi.Size() > maxMessageSize {
return errors.New("Cannot add file, file bigger than messge size") return errors.New("cannot add file, file bigger than messge size")
} }
var totalsize int64 var totalsize int64
totalsize = 0 totalsize = 0
@ -22,7 +22,7 @@ func (msg *UserMessage) AddFile(filename string, maxMessageSize int64) error {
} }
totalsize += fi.Size() totalsize += fi.Size()
if totalsize > maxMessageSize { if totalsize > maxMessageSize {
return errors.New("Cannot add file, too many files, max message size exceeded") return errors.New("cannot add file, too many files, max message size exceeded")
} }
data, err := os.ReadFile(filename) data, err := os.ReadFile(filename)
if err != nil { if err != nil {

View File

@ -1,8 +1,8 @@
package meowlib_test package meowlib_test
import ( import (
"io/ioutil"
"log" "log"
"os"
"testing" "testing"
"forge.redroom.link/yves/meowlib" "forge.redroom.link/yves/meowlib"
@ -19,10 +19,10 @@ func TestServerMessageSerialization(t *testing.T) {
if err != nil { if err != nil {
log.Fatalln("Failed to encode address book:", err) log.Fatalln("Failed to encode address book:", err)
} }
if err := ioutil.WriteFile("test", out, 0644); err != nil { if err := os.WriteFile("test", out, 0644); err != nil {
log.Fatalln("Failed to write address book:", err) log.Fatalln("Failed to write address book:", err)
} }
in, err := ioutil.ReadFile("test") in, err := os.ReadFile("test")
if err != nil { if err != nil {
log.Fatalln("Error reading file:", err) log.Fatalln("Error reading file:", err)
} }