Skip to content

Commit

Permalink
Remove deprecated ioutil
Browse files Browse the repository at this point in the history
  • Loading branch information
pgundlach committed Aug 27, 2023
1 parent 814c259 commit a218863
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 16 deletions.
4 changes: 2 additions & 2 deletions helper/changelog/changelog.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 3,7 @@ package changelog

import (
"encoding/xml"
"io/ioutil"
"os"
"path/filepath"

"github.com/speedata/xts/helper/config"
Expand Down Expand Up @@ -32,7 32,7 @@ type Changelog struct {
}

func parseChangelog(filename string) (*Changelog, error) {
data, err := ioutil.ReadFile(filename)
data, err := os.ReadFile(filename)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions helper/genschema/commandsxml.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 2,7 @@ package genschema

import (
"encoding/xml"
"io/ioutil"
"os"
"path/filepath"
"strings"
)
Expand Down Expand Up @@ -103,7 103,7 @@ type commandsXML struct {
}

func readCommandsFile(basedir string) (*commandsXML, error) {
commandsdata, err := ioutil.ReadFile(filepath.Join(basedir, "doc", "commands-xml", "commands.xml"))
commandsdata, err := os.ReadFile(filepath.Join(basedir, "doc", "commands-xml", "commands.xml"))
if err != nil {
return nil, err
}
Expand Down
10 changes: 5 additions & 5 deletions helper/genschema/genschema.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 3,7 @@ package genschema

import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"

Expand Down Expand Up @@ -36,7 36,7 @@ func DoThings(cfg *config.Config) error {
if err != nil {
return err
}
err = ioutil.WriteFile(rngSchemaENPath, buf, 0644)
err = os.WriteFile(rngSchemaENPath, buf, 0644)
if err != nil {
return err
}
Expand All @@ -45,7 45,7 @@ func DoThings(cfg *config.Config) error {
if err != nil {
return err
}
err = ioutil.WriteFile(rngSchemaDEPath, buf, 0644)
err = os.WriteFile(rngSchemaDEPath, buf, 0644)
if err != nil {
return err
}
Expand All @@ -68,15 68,15 @@ func DoThings(cfg *config.Config) error {
if err != nil {
return err
}
err = ioutil.WriteFile(rngSchemaENPath, buf, 0644)
err = os.WriteFile(rngSchemaENPath, buf, 0644)
if err != nil {
return err
}
buf, err = genRelaxNGSchema(c, "de", true)
if err != nil {
return err
}
err = ioutil.WriteFile(rngSchemaDEPath, buf, 0644)
err = os.WriteFile(rngSchemaDEPath, buf, 0644)
if err != nil {
return err
}
Expand Down
3 changes: 1 addition & 2 deletions xts/luacsv/luacsv.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 5,6 @@ import (
"encoding/csv"
"fmt"
"io"
"io/ioutil"
"os"
"regexp"

Expand Down Expand Up @@ -65,7 64,7 @@ func decode(l *lua.LState) int {
rd = charmap.ISO8859_1.NewDecoder().Reader(rd)
}

data, err := ioutil.ReadAll(rd)
data, err := io.ReadAll(rd)
if err != nil {
return lerr(l, err.Error())
}
Expand Down
4 changes: 2 additions & 2 deletions xts/luaxml/luaxml.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 4,7 @@ import (
"bytes"
"encoding/xml"
"fmt"
"io/ioutil"
"os"

lua "github.com/yuin/gopher-lua"
)
Expand Down Expand Up @@ -120,7 120,7 @@ func encodeTable(l *lua.LState) int {
l.SetTop(0)
l.Push(lua.LTrue)
enc.Flush()
ioutil.WriteFile(filename, b.Bytes(), 0644)
os.WriteFile(filename, b.Bytes(), 0644)
return 1
}

Expand Down
5 changes: 2 additions & 3 deletions xts/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 3,6 @@ package main
import (
"fmt"
"io"
"io/ioutil"
"log/slog"
"os"
"os/exec"
Expand Down Expand Up @@ -150,12 149,12 @@ func scaffold(extra ...string) error {
</Layout>
`

err = ioutil.WriteFile("data.xml", []byte(dataTxt), 0644)
err = os.WriteFile("data.xml", []byte(dataTxt), 0644)
if err != nil {
return err
}

err = ioutil.WriteFile("layout.xml", []byte(layoutTxt), 0644)
err = os.WriteFile("layout.xml", []byte(layoutTxt), 0644)
if err != nil {
return err
}
Expand Down

0 comments on commit a218863

Please sign in to comment.